├── .gitignore ├── index.php ├── languages ├── index.php ├── networksharedmedia-de_DE.mo ├── networksharedmedia-de_DE.po ├── networksharedmedia-default.pot ├── networksharedmedia-es_ES.mo ├── networksharedmedia-es_ES.po ├── networksharedmedia-nl_NL.mo ├── networksharedmedia-nl_NL.po ├── networksharedmedia-sr_RS.mo └── networksharedmedia-sr_RS.po ├── network_shared_media.php ├── readme.txt ├── screenshot-1.png ├── screenshot-2.png ├── screenshot-3.png └── todo-wishes.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.bbprojectd 2 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /languages/index.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /languages/networksharedmedia-de_DE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/languages/networksharedmedia-de_DE.mo -------------------------------------------------------------------------------- /languages/networksharedmedia-de_DE.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 Network Shared Media 2 | # This file is distributed under the same license as the Network Shared Media package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Network Shared Media\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/network_shared_media\n" 7 | "POT-Creation-Date: 2012-06-06 13:42:31+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2014-09-16 11:10+0100\n" 12 | "Last-Translator: \n" 13 | "Language-Team: realloc \n" 14 | "X-Generator: Poedit 1.5.7\n" 15 | "Language: de_DE\n" 16 | 17 | #: media-upload.php:27 18 | msgid "You do not have permission to upload files to site: " 19 | msgstr "Du hast keine Berechtigung zum Hochladen von Dateien zur Website:" 20 | 21 | #. #-#-#-#-# network_shared_media.pot (Network Shared Media 0.8) #-#-#-#-# 22 | #. Plugin Name of the plugin/theme 23 | #: network_shared_media.php:18 24 | msgid "Network Shared Media" 25 | msgstr "" 26 | 27 | #: network_shared_media.php:144 28 | msgid "You don't have access to any other sites media..." 29 | msgstr "Du hast keinen Zugriff auf die Mediengalerien in anderen Websites..." 30 | 31 | #: network_shared_media.php:202 32 | msgid "Selected site:" 33 | msgstr "Ausgewählte Website:" 34 | 35 | #: network_shared_media.php:208 network_shared_media.php:218 36 | #: network_shared_media.php:230 37 | msgid "Select site:" 38 | msgstr "Wähle Website:" 39 | 40 | #: network_shared_media.php:230 41 | msgid "Select »" 42 | msgstr "Wähle »" 43 | 44 | #. Plugin URI of the plugin/theme 45 | msgid "http://wordpress.org/extend/plugins/network-shared-media/" 46 | msgstr "" 47 | 48 | #. Description of the plugin/theme 49 | msgid "" 50 | "This plugin adds a new tab to the \"Add Media\" window, allowing you to " 51 | "access media in other blogs. Based on an idea of Aaron Eaton" 52 | msgstr "" 53 | "Dieses Plugin fügt dem \"Medien hinzufügen\" Fenster einen neuen Reiter " 54 | "hinzu, der den Zugriff auf die Medien in anderen Blogs ermöglicht. Basiert " 55 | "auf einer Idee von Aaron Eaton" 56 | 57 | #. Author of the plugin/theme 58 | msgid "Joost de Keijzer" 59 | msgstr "" 60 | 61 | #. Author URI of the plugin/theme 62 | msgid "http://dekeijzer.org/" 63 | msgstr "" 64 | -------------------------------------------------------------------------------- /languages/networksharedmedia-default.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 Network Shared Media 2 | # This file is distributed under the same license as the Network Shared Media package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Network Shared Media\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/network_shared_media\n" 7 | "POT-Creation-Date: 2012-06-06 13:42:31+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: Joost de Keijzer \n" 13 | "Language-Team: LANGUAGE \n" 14 | 15 | #: media-upload.php:27 16 | msgid "You do not have permission to upload files to site: " 17 | msgstr "" 18 | 19 | #. #-#-#-#-# network_shared_media.pot (Network Shared Media 0.8) #-#-#-#-# 20 | #. Plugin Name of the plugin/theme 21 | #: network_shared_media.php:18 22 | msgid "Network Shared Media" 23 | msgstr "" 24 | 25 | #: network_shared_media.php:144 26 | msgid "You don't have access to any other sites media..." 27 | msgstr "" 28 | 29 | #: network_shared_media.php:202 30 | msgid "Selected site:" 31 | msgstr "" 32 | 33 | #: network_shared_media.php:208 network_shared_media.php:218 34 | #: network_shared_media.php:230 35 | msgid "Select site:" 36 | msgstr "" 37 | 38 | #: network_shared_media.php:230 39 | msgid "Select »" 40 | msgstr "" 41 | 42 | #. Plugin URI of the plugin/theme 43 | msgid "http://wordpress.org/extend/plugins/network-shared-media/" 44 | msgstr "" 45 | 46 | #. Description of the plugin/theme 47 | msgid "" 48 | "This plugin adds a new tab to the \"Add Media\" window, allowing you to " 49 | "access media in other blogs. Based on an idea of Aaron Eaton" 50 | msgstr "" 51 | 52 | #. Author of the plugin/theme 53 | msgid "Joost de Keijzer" 54 | msgstr "" 55 | 56 | #. Author URI of the plugin/theme 57 | msgid "http://dekeijzer.org/" 58 | msgstr "" 59 | -------------------------------------------------------------------------------- /languages/networksharedmedia-es_ES.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/languages/networksharedmedia-es_ES.mo -------------------------------------------------------------------------------- /languages/networksharedmedia-es_ES.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 Network Shared Media 2 | # This file is distributed under the same license as the Network Shared Media package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Network Shared Media\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/network_shared_media\n" 7 | "POT-Creation-Date: 2012-06-06 13:42:31+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2013-11-08 17:01-0300\n" 12 | "Last-Translator: Juan Ignacio Rodriguez \n" 13 | "Language-Team: \n" 14 | "X-Generator: Poedit 1.5.7\n" 15 | "Language: Spanish\n" 16 | 17 | #: media-upload.php:27 18 | msgid "You do not have permission to upload files to site: " 19 | msgstr "No tienes los permisos suficientes para subir archivos al sitio:" 20 | 21 | #. #-#-#-#-# network_shared_media.pot (Network Shared Media 0.8) #-#-#-#-# 22 | #. Plugin Name of the plugin/theme 23 | #: network_shared_media.php:18 24 | msgid "Network Shared Media" 25 | msgstr "Medios Compartidos de Red" 26 | 27 | #: network_shared_media.php:144 28 | msgid "You don't have access to any other sites media..." 29 | msgstr "No tienes acceso a los medios de ningún otro sitio..." 30 | 31 | #: network_shared_media.php:202 32 | msgid "Selected site:" 33 | msgstr "Sitio seleccionado:" 34 | 35 | #: network_shared_media.php:208 network_shared_media.php:218 36 | #: network_shared_media.php:230 37 | msgid "Select site:" 38 | msgstr "Seleccionar sitio:" 39 | 40 | #: network_shared_media.php:230 41 | msgid "Select »" 42 | msgstr "Seleccionar »" 43 | 44 | #. Plugin URI of the plugin/theme 45 | msgid "http://wordpress.org/extend/plugins/network-shared-media/" 46 | msgstr "" 47 | 48 | #. Description of the plugin/theme 49 | msgid "" 50 | "This plugin adds a new tab to the \"Add Media\" window, allowing you to " 51 | "access media in other blogs. Based on an idea of Aaron Eaton" 52 | msgstr "" 53 | "Este plugin agrega una nueva solapa a la ventana \"Añadir objeto\", " 54 | "permitiendo el acceso a los medios de otros blogs en la red.\vBasado en la " 55 | "idea de Aaron Eaton" 56 | 57 | #. Author of the plugin/theme 58 | msgid "Joost de Keijzer" 59 | msgstr "" 60 | 61 | #. Author URI of the plugin/theme 62 | msgid "http://dekeijzer.org/" 63 | msgstr "" 64 | -------------------------------------------------------------------------------- /languages/networksharedmedia-nl_NL.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/languages/networksharedmedia-nl_NL.mo -------------------------------------------------------------------------------- /languages/networksharedmedia-nl_NL.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 2 | # This file is distributed under the same license as the package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Network Shared Media\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/network_shared_media\n" 7 | "POT-Creation-Date: 2012-06-06 13:42:31+00:00\n" 8 | "PO-Revision-Date: \n" 9 | "Last-Translator: joost de keijzer \n" 10 | "Language-Team: \n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=UTF-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "X-Poedit-Language: Dutch\n" 15 | "X-Poedit-Country: NETHERLANDS\n" 16 | "X-Poedit-SourceCharset: utf-8\n" 17 | "Plural-Forms: nplurals=2; plural=n != 1;\n" 18 | 19 | # networksharedmedia 20 | #: media-upload.php:27 21 | msgid "You do not have permission to upload files to site: " 22 | msgstr "Je hebt geen rechten om bestanden te uploaden naar site: " 23 | 24 | # networksharedmedia 25 | #. #-#-#-#-# network_shared_media.pot (Network Shared Media 0.8) #-#-#-#-# 26 | #. Plugin Name of the plugin/theme 27 | #: network_shared_media.php:18 28 | msgid "Network Shared Media" 29 | msgstr "Netwerk Gedeelde Media" 30 | 31 | # networksharedmedia 32 | #: network_shared_media.php:144 33 | msgid "You don't have access to any other sites media..." 34 | msgstr "Je hebt geen toegang tot media van andere sites..." 35 | 36 | # networksharedmedia 37 | #: network_shared_media.php:202 38 | msgid "Selected site:" 39 | msgstr "Selecteer site:" 40 | 41 | # networksharedmedia 42 | #: network_shared_media.php:208 43 | #: network_shared_media.php:218 44 | #: network_shared_media.php:230 45 | msgid "Select site:" 46 | msgstr "Selecteer site:" 47 | 48 | # networksharedmedia 49 | #: network_shared_media.php:230 50 | msgid "Select »" 51 | msgstr "Selecteer »" 52 | 53 | #. Plugin URI of the plugin/theme 54 | msgid "http://wordpress.org/extend/plugins/network-shared-media/" 55 | msgstr "" 56 | 57 | #. Description of the plugin/theme 58 | msgid "This plugin adds a new tab to the \"Add Media\" window, allowing you to access media in other blogs. Based on an idea of Aaron Eaton" 59 | msgstr "" 60 | 61 | #. Author of the plugin/theme 62 | msgid "Joost de Keijzer" 63 | msgstr "" 64 | 65 | #. Author URI of the plugin/theme 66 | msgid "http://dekeijzer.org/" 67 | msgstr "" 68 | 69 | -------------------------------------------------------------------------------- /languages/networksharedmedia-sr_RS.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/languages/networksharedmedia-sr_RS.mo -------------------------------------------------------------------------------- /languages/networksharedmedia-sr_RS.po: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 2 | # This file is distributed under the same license as the package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Network Shared Media\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/network_shared_media\n" 7 | "POT-Creation-Date: 2012-06-06 13:42:31+00:00\n" 8 | "PO-Revision-Date: \n" 9 | "Last-Translator: Borisa Djuraskovic \n" 10 | "Language-Team: \n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=UTF-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "X-Poedit-SourceCharset: utf-8\n" 15 | "Plural-Forms: nplurals=2; plural=n != 1;\n" 16 | "Language: nl_NL\n" 17 | "X-Generator: Poedit 1.5.7\n" 18 | 19 | # networksharedmedia 20 | #: media-upload.php:27 21 | msgid "You do not have permission to upload files to site: " 22 | msgstr "Nema dozvolu za upload fajlova na sajt:" 23 | 24 | # networksharedmedia 25 | #. #-#-#-#-# network_shared_media.pot (Network Shared Media 0.8) #-#-#-#-# 26 | #. Plugin Name of the plugin/theme 27 | #: network_shared_media.php:18 28 | msgid "Network Shared Media" 29 | msgstr "Network Shared Media" 30 | 31 | # networksharedmedia 32 | #: network_shared_media.php:144 33 | msgid "You don't have access to any other sites media..." 34 | msgstr "Nemate pristup nijednom drugom medija sajtu" 35 | 36 | # networksharedmedia 37 | #: network_shared_media.php:202 38 | msgid "Selected site:" 39 | msgstr "Izabrani sajt:" 40 | 41 | # networksharedmedia 42 | #: network_shared_media.php:208 network_shared_media.php:218 43 | #: network_shared_media.php:230 44 | msgid "Select site:" 45 | msgstr "Izabrani sajt:" 46 | 47 | # networksharedmedia 48 | #: network_shared_media.php:230 49 | msgid "Select »" 50 | msgstr "Izaberi »" 51 | 52 | #. Plugin URI of the plugin/theme 53 | msgid "http://wordpress.org/extend/plugins/network-shared-media/" 54 | msgstr "http://wordpress.org/extend/plugins/network-shared-media/" 55 | 56 | #. Description of the plugin/theme 57 | msgid "" 58 | "This plugin adds a new tab to the \"Add Media\" window, allowing you to " 59 | "access media in other blogs. Based on an idea of Aaron Eaton" 60 | msgstr "" 61 | "Ovaj plugin dodaje novi tab u \"Dodaj Medije\" prozor, dozvoljavajući vam da " 62 | "pristupite medijima u vašim blogovima. Zasnovano na Aaron Eaton ideji " 63 | 64 | #. Author of the plugin/theme 65 | msgid "Joost de Keijzer" 66 | msgstr "Joost de Keijzer" 67 | 68 | #. Author URI of the plugin/theme 69 | msgid "http://dekeijzer.org/" 70 | msgstr "http://dekeijzer.org/" 71 | -------------------------------------------------------------------------------- /network_shared_media.php: -------------------------------------------------------------------------------- 1 | __('Network Shared Media', 'networksharedmedia')); 21 | return array_merge($tabs, $newtab); 22 | } 23 | 24 | // Load media_nsm_process() into the existing iframe 25 | function network_shared_media_upload_shared_media() { 26 | $nsm = new network_shared_media(); 27 | return wp_iframe(array( $nsm, 'media_upload_shared_media' ), array()); 28 | } 29 | 30 | function network_shared_media_init() { 31 | if ( current_user_can('upload_files') ) { 32 | load_plugin_textdomain( 'networksharedmedia', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 33 | add_filter('media_upload_tabs', 'network_shared_media_menu'); 34 | add_action('media_upload_shared_media', 'network_shared_media_upload_shared_media'); 35 | add_action('wp_ajax_nsm-media-upload', 'network_shared_media_media_upload'); 36 | } 37 | } 38 | add_action( 'init', 'network_shared_media_init' ); 39 | 40 | function network_shared_media_media_upload() { 41 | global $blog_id, $post; 42 | 43 | if( isset( $_POST['send'] ) ) { 44 | $nsm_blog_id = (int) $_GET['blog_id']; 45 | reset( $_POST['send'] ); 46 | $nsm_send_id = (int) key( $_POST['send'] ); 47 | } 48 | 49 | /* copied from wp-admin/inculdes/ajax-actions.php wp_ajax_send_attachment_to_editor() */ 50 | if ( isset( $nsm_blog_id ) && isset( $nsm_send_id ) ) { 51 | switch_to_blog( $nsm_blog_id ); 52 | if (!current_user_can('upload_files')) { 53 | $current_blog_name = get_bloginfo('name'); 54 | restore_current_blog(); 55 | wp_die(__('You do not have permission to upload files to site: ') . $current_blog_name ); 56 | } 57 | 58 | $attachment = wp_unslash( $_POST['attachments'][$nsm_send_id] ); 59 | $id = $nsm_send_id; 60 | 61 | if ( ! $post = get_post( $id ) ) 62 | wp_send_json_error(); 63 | 64 | if ( 'attachment' != $post->post_type ) 65 | wp_send_json_error(); 66 | 67 | $rel = $url = ''; 68 | $html = $title = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; 69 | if ( ! empty( $attachment['url'] ) ) { 70 | $url = $attachment['url']; 71 | if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) 72 | $rel = ' rel="attachment wp-att-' . $id . '"'; 73 | $html = '' . $html . ''; 74 | } 75 | 76 | if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { 77 | $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; 78 | $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; 79 | $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; 80 | $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; 81 | $title = ''; // We no longer insert title tags into tags, as they are redundant. 82 | $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); 83 | } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) { 84 | global $wp_embed; 85 | $meta = get_post_meta( $id, '_wp_attachment_metadata', true ); 86 | $html = $wp_embed->shortcode( $meta, $url ); 87 | } 88 | 89 | /** This filter is documented in wp-admin/includes/media.php */ 90 | $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); 91 | 92 | // replace wp-image-, wp-att- and attachment_ 93 | $html = preg_replace( 94 | array( 95 | '#(caption id="attachment_)(\d+")#', // mind the quotes! 96 | '#(wp-image-|wp-att-)(\d+)#' 97 | ), 98 | array( 99 | sprintf('${1}nsm_%s_${2}', esc_attr($nsm_blog_id)), 100 | sprintf('${1}nsm-%s-${2}', esc_attr($nsm_blog_id)), 101 | ), 102 | $html 103 | ); 104 | 105 | if( isset($_POST['chromeless']) && $_POST['chromeless'] ) { 106 | // WP3.5+ media browser is identified by the 'chromeless' parameter 107 | exit($html); 108 | } else { 109 | return media_send_to_editor($html); 110 | } 111 | } 112 | } 113 | 114 | class network_shared_media { 115 | var $blogs = array(); 116 | var $media_items = ''; 117 | var $current_blog_id; 118 | 119 | function __construct() { 120 | global $blog_id; 121 | $this->current_blog_id = $blog_id; 122 | 123 | /* copied from depricated get_blog_list */ 124 | global $wpdb; 125 | $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A ); 126 | 127 | $this->blogs = array(); 128 | $sort_array = array(); 129 | 130 | foreach ( (array) $blogs as $details ) { 131 | if ( !current_user_can_for_blog( $details['blog_id'], 'upload_files') || $details['blog_id'] == $this->current_blog_id ) continue; 132 | 133 | $details['name'] = get_blog_option( $details['blog_id'], 'blogname' ); 134 | $this->blogs[] = $details; 135 | $sort_array[] = strtolower ( $details['name'] ); 136 | } 137 | array_multisort( $sort_array, SORT_ASC, $this->blogs ); 138 | } 139 | 140 | function get_media_items( $post_id, $errors ) { 141 | global $blog_id; 142 | $output = get_media_items( $post_id, $errors ); 143 | 144 | // remove edit button pre WP3.5 145 | $output = preg_replace( "%

]+>

%s", '', $output ); 146 | 147 | // remove edit button WP3.5+ 148 | $output = preg_replace( "%

%s", '', $output ); 149 | 150 | // remove delete link 151 | $output = preg_replace( "%%s", '', $output ); 152 | $output = preg_replace( "%
blogs ) == 0 ) { 170 | echo '

' . __("You don't have access to any other sites media...", 'networksharedmedia' ) . '

'; 171 | return; 172 | } 173 | 174 | // set the first part of the form action url now, to the current active site, to prevent X-Frame-Options problems 175 | $form_action_url = admin_url('admin-ajax.php?action=nsm-media-upload'); 176 | 177 | $nsm_blog_id = null; 178 | if( !array_key_exists( 'blog_id', $_GET ) ) $_GET['blog_id'] = null; 179 | 180 | foreach( $this->blogs as $blog ) { 181 | if( $_GET['blog_id'] == $blog['blog_id'] ) { 182 | $nsm_blog_id = $blog['blog_id']; 183 | break; 184 | } 185 | } 186 | 187 | if( null == $nsm_blog_id ) 188 | $nsm_blog_id = $this->blogs[0]['blog_id']; 189 | 190 | switch_to_blog( $nsm_blog_id ); 191 | ?> 192 | 193 | 214 | 215 |
216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 228 | 229 |
    230 | blogs ) == 1 ) { 233 | $blog = reset( $this->blogs ); 234 | echo "
  • " . __('Selected site:', 'networksharedmedia' ) . "
  • " . "
  • $blog['blog_id'], 'paged'=>false))) . "' class='current'>" . $blog['name'] . '' . '
  • '; 235 | } else { 236 | $all_blog_names = array(); 237 | foreach ( $this->blogs as $blog ) { 238 | $all_blog_names[] = $blog['name']; 239 | } 240 | if( strlen( __('Select site:', 'networksharedmedia' ) . ' ' . implode( ' | ', $all_blog_names ) ) < 71 ) { 241 | $blog_links = array(); 242 | foreach ( $this->blogs as $blog ) { 243 | $class = ''; 244 | 245 | if ( $blog['blog_id'] == $blog_id ) 246 | $class = ' class="current"'; 247 | 248 | $blog_links[] = "
  • $blog['blog_id'], 'paged'=>false))) . "'$class>" . $blog['name'] . ''; 249 | } 250 | echo "
  • " . __('Select site:', 'networksharedmedia' ) . "
  • " . implode(' | ', $blog_links ) . ''; 251 | unset($blog_links); 252 | } else { 253 | $blog_options = array(); 254 | foreach ( $this->blogs as $blog ) { 255 | $selected = ''; 256 | 257 | if ( $blog['blog_id'] == $blog_id ) 258 | $selected = ' selected="selected"'; 259 | 260 | $blog_options[] = "'; 261 | } 262 | echo "
  • " . __('Select site:', 'networksharedmedia' ) . "
  • ' . get_submit_button( __( 'Select »', 'networksharedmedia' ), 'secondary', 'nsm-post-query-submit', false ) . '
  • '; 263 | unset($blog_options); 264 | } 265 | unset($all_blog_names); 266 | } 267 | ?> 268 |
269 | 270 | 275 | 276 |
    277 | $reals ) 282 | foreach ( $reals as $real ) 283 | if ( isset($num_posts[$_type]) ) 284 | $num_posts[$_type] += $_num_posts[$real]; 285 | else 286 | $num_posts[$_type] = $_num_posts[$real]; 287 | // If available type specified by media button clicked, filter by that type 288 | if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { 289 | $_GET['post_mime_type'] = $type; 290 | list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 291 | } 292 | if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) 293 | $class = ' class="current"'; 294 | else 295 | $class = ''; 296 | $type_links[] = "
  • 'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types').""; 297 | foreach ( $post_mime_types as $mime_type => $label ) { 298 | $class = ''; 299 | 300 | if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) 301 | continue; 302 | 303 | if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) 304 | $class = ' class="current"'; 305 | 306 | $type_links[] = "
  • $mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "" . number_format_i18n( $num_posts[$mime_type] ) . '') . ''; 307 | } 308 | echo implode(' |
  • ', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . ''; 309 | unset($type_links); 310 | ?> 311 |
312 | 313 |
314 | 315 | add_query_arg( 'paged', '%#%' ), 318 | 'format' => '', 319 | 'prev_text' => __('«'), 320 | 'next_text' => __('»'), 321 | 'total' => ceil($wp_query->found_posts / 10), 322 | 'current' => $_GET['paged'] 323 | )); 324 | 325 | if ( $page_links ) 326 | echo "
$page_links
"; 327 | ?> 328 | 329 |
330 | posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; 333 | 334 | $arc_result = $wpdb->get_results( $arc_query ); 335 | 336 | $month_count = count($arc_result); 337 | 338 | if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> 339 | 358 | 359 | 360 | 361 | 362 |
363 | 364 |
365 |
366 |
367 | 368 |
369 | 370 | 371 | 372 | 373 | 377 | 400 | 401 | 402 | 413 | 414 |
415 | 416 | get_media_items(null, $errors); ?> 417 |
418 |

419 |
420 | see the new tab! 45 | 46 | == Upgrade Notice == 47 | 48 | * I've dropped support for WordPress versions below 3.5 49 | * There is an issue with the "edit image" functionality in the post editor of WordPress 3.9, please see the FAQ 50 | 51 | == Frequently Asked Questions == 52 | 53 | = Editing an image in WordPress 3.9 shows the wrong image! = 54 | 55 | Yes, I know :-( 56 | 57 | Starting from WordPress 3.9, when editing an image in the post editor, the original image data is retrieved from the server using only the image id. Using NSM, this will be the ID from a different blog. When, by coincidence, the current blog also has an attachment with that ID, the information for that image is displayed. 58 | 59 | v0.10.0 of my plugin has a fix for newly inserted images, but old embeds will not be changed (please see [this forum post](https://wordpress.org/support/topic/using-wordpress-39-editing-an-image-shows-the-wrong-information) for more info). 60 | 61 | If you encounter this, the most straight-forward solution is to: 62 | 63 | 1. Cancel the image edit 64 | 2. Go to the text view of the post 65 | 3. When your image has a caption, clear the id attribute of the caption shortcode 66 | 4. Also remove the `wp-image-` and `wp-att-` classes from the image tag 67 | 5. Return to Visual mode and try and edit the image again 68 | 69 | Sorry for the inconvenience... 70 | 71 | = About Permissions = 72 | 73 | This plugin depends on the global WordPress blog permissions for viewing and editing Media. 74 | 75 | Only blogs where the user has 'upload_files' permission are shown in the Network Shared Media tab. 76 | 77 | If a user doesn't have the 'upload_files' permission on the current (active) blog, the tab isn't shown at all since that user can't access the Add Media pop-up window. 78 | 79 | = I still can't see the site listed! = 80 | 81 | A site can have several attributes which can be set through /wp-admin/network/sites.php . 82 | 83 | This plugin only shows sites which attributes are set as follows: 84 | 85 | * Public: true 86 | * Archived: false 87 | * Spam: false 88 | * Delete: false 89 | * Mature: ignored 90 | 91 | == Screenshots == 92 | 1. New tab added to the Add Media popup window 93 | 2. The Network Shared Media tab lists the media per site 94 | 3. Show a selected image and "Insert into Post" 95 | 96 | == Changelog == 97 | 98 | = 0.12 = 99 | * Deprecated 100 | 101 | = 0.11 = 102 | * Removed media-upload.php file and the direct request for it. It was incompatible with setups where the plugins directory had been moved. Now, requests are done through /wp-admin/admin-ajax.php. 103 | * Tested with WordPress 4.3 104 | 105 | = 0.10.1 = 106 | * Added German translation (by realloc) 107 | 108 | = 0.10.0 = 109 | * Changes all image/caption id's and id-dependent classnames to include `nsm--` to circumvent WordPress 3.9 editor issues (see FAQ or [this forum post](https://wordpress.org/support/topic/using-wordpress-39-editing-an-image-shows-the-wrong-information)) 110 | * New "base" for the insertion code 111 | * Supports Video and Audio shortcode insertion 112 | 113 | = 0.9.6 = 114 | * Bugfix where, after selecting an image, reopening the Media Browser would result in an empty screen. 115 | * Tested with WordPress 3.8. 116 | 117 | = 0.9.5 = 118 | * Added translations for Spanish (es_ES by Juan Ignacio Rodriguez) and Serbo-Croatian (sr_RS by Borisa Djuraskovic). Thank you! 119 | * Bugfix for newer WordPress where original media tabs would show. 120 | 121 | = 0.9.4 = 122 | * Minor bugfix for WP3.5 (remove the "Edit picture" button) 123 | 124 | = 0.9.3 = 125 | * Set is_admin() to true, fixing issues with Contact Form 7 (and possibly others) 126 | 127 | = 0.9.2 = 128 | * bugfix for cross-domain errors in "multiple domain" installations 129 | 130 | = 0.9.1 = 131 | * some speed improvements 132 | * sorting of sites 133 | 134 | = 0.9 = 135 | * When many sites are available, the site-selection becomes a drop-down list (as suggested by SooBahkDo) 136 | * Ignore "mature" site attribute 137 | * tested with WP3.4RC 138 | 139 | = 0.8 = 140 | * fixed some embarrassing typos 141 | 142 | = 0.7 = 143 | * i18n (feel free to contact me for translations) 144 | * Updated read-me 145 | * Added screenshot 146 | 147 | = 0.6 = 148 | * fixed bug where restore_current_blog would give unexpected results (when number of sites > 2) 149 | * checking for correct permissions: upload_files permission required for both the "active" site as the networked sites 150 | * to reduce server load: choose blog to display media of (in stead of just showing them all) 151 | 152 | = 0.5 = 153 | * first public version 154 | -------------------------------------------------------------------------------- /screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/screenshot-1.png -------------------------------------------------------------------------------- /screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/screenshot-2.png -------------------------------------------------------------------------------- /screenshot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joostdekeijzer/wp_network_shared_media/d72ee6451cbfeddadee60292d0d1c5201eec1770/screenshot-3.png -------------------------------------------------------------------------------- /todo-wishes.txt: -------------------------------------------------------------------------------- 1 | == Issues == 2 | http://wordpress.org/support/topic/some-libraries-show-broken-images 3 | 4 | == In random order == 5 | 6 | - insert media does not work for "main" blog (blog_id=1) quickpress 7 | - add option to replace "media" tab altogether 8 | - make above option cross-network?!? 9 | - add "featured image" link (or don't remove it and make it work) 10 | - make gallery shortcode work with networked images (see gallery_shortcode function) 11 | - WP3.9 edit image returns wrong image, see https://wordpress.org/support/topic/using-wordpress-39-editing-an-image-shows-the-wrong-information 12 | --------------------------------------------------------------------------------