Changeset 459721
- Timestamp:
- 11/05/2011 07:01:05 PM (14 years ago)
- Location:
- multisite-dashboard-switcher/trunk
- Files:
-
- 2 edited
-
multisite-dashboard-switcher.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multisite-dashboard-switcher/trunk/multisite-dashboard-switcher.php
r458665 r459721 3 3 Plugin Name: Multisite Dashboard Switcher 4 4 Plugin URI: http://samjlevy.com/msds 5 Description: Adds a menu to the Admin Bar for easy switching between Multisite dashboards.6 Version: 1. 05 Description: Adds a menu to the admin bar for easy switching between multisite dashboards. 6 Version: 1.1 7 7 Author: Sam J Levy 8 8 Author URI: http://samjlevy.com/ 9 9 */ 10 10 ?><?php 11 /* Copyright 2011 Sam J Levy (email : sam@samjlevy.com) 11 /* 12 Copyright 2011 Sam J Levy (email : sam@samjlevy.com) 12 13 13 This program is free software; you can redistribute it and/or modify14 it under the terms of the GNU General Public License, version 2, as15 published by the Free Software Foundation.14 This program is free software; you can redistribute it and/or modify 15 it under the terms of the GNU General Public License, version 2, as 16 published by the Free Software Foundation. 16 17 17 This program is distributed in the hope that it will be useful,18 but WITHOUT ANY WARRANTY; without even the implied warranty of19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 GNU General Public License for more details.18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 21 22 22 You should have received a copy of the GNU General Public License23 along with this program; if not, write to the Free Software24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 26 */ 26 27 ?><?php 27 28 add_action('admin_bar_menu','msds',1000); 28 add_action('network_admin_menu','msds_ init');29 add_action('admin_post_update_my_settings','msds_ options_save');29 add_action('network_admin_menu','msds_settings_menu'); 30 add_action('admin_post_update_my_settings','msds_settings_save'); 30 31 register_uninstall_hook(__FILE__,'msds_uninstall'); 31 32 32 function msds_ init() {33 add_submenu_page('settings.php','Multisite Dashboard Switcher Options','Multisite Dashboard Switcher','manage_network_ options','msds-options','msds_options');33 function msds_settings_menu() { 34 add_submenu_page('settings.php','Multisite Dashboard Switcher Options','Multisite Dashboard Switcher','manage_network_settings','msds-options','msds_settings'); 34 35 } 35 36 36 function msds_ options() {37 function msds_settings() { 37 38 $msds_group = get_site_option('msds_group'); 38 39 echo "<h2>Multisite Dashboard Switcher - Options</h2>"; … … 45 46 } 46 47 47 function msds_ options_save() {48 function msds_settings_save() { 48 49 check_admin_referer('msds_nonce'); 49 if(!current_user_can('manage_network_ options')) return;50 if(!current_user_can('manage_network_settings')) return; 50 51 if(isset($_POST['msds_group'])) update_site_option('msds_group', 'alpha'); 51 52 else delete_site_option('msds_group'); … … 56 57 function msds_pages($type,$id,$url) { 57 58 global $wp_admin_bar; 58 if($type == "site") $pages = array('dashboard'=>'index.php',' posts'=>'edit.php','media'=>'media.php','links'=>'link-manager.php','pages'=>'edit.php?post_type=page','comments'=>'edit-comments.php','appearance'=>'themes.php','plugins'=>'plugins.php','users'=>'users.php','tools'=>'tools.php','settings'=>'options-general.php');59 if($type == "site") $pages = array('dashboard'=>'index.php','visit'=>'','posts'=>'edit.php','media'=>'media.php','links'=>'link-manager.php','pages'=>'edit.php?post_type=page','comments'=>'edit-comments.php','appearance'=>'themes.php','plugins'=>'plugins.php','users'=>'users.php','tools'=>'tools.php','settings'=>'options-general.php'); 59 60 elseif($type == "network") $pages = array('dashboard'=>'index.php','sites'=>'sites.php','users'=>'users.php','themes'=>'themes.php','plugins'=>'plugins.php','settings'=>'settings.php','updates'=>'update-core.php'); 60 61 else return false; 61 foreach($pages as $key=>$value) $wp_admin_bar->add_menu(array('parent'=>'msds_'.$id,'id' =>'msds_'.$id.'_'.$key,'title'=>ucfirst($key),'href'=>$url.'/'.$value)); 62 foreach($pages as $key=>$value) { 63 if($key=="visit") $wp_admin_bar->add_menu(array('parent'=>'msds_'.$id,'id' =>'msds_'.$id.'_visit','title'=>ucfirst($key),'href'=>str_replace('wp-admin','',$url))); 64 else $wp_admin_bar->add_menu(array('parent'=>'msds_'.$id,'id' =>'msds_'.$id.'_'.$key,'title'=>ucfirst($key),'href'=>$url.'/'.$value)); 65 } 62 66 } 63 67 64 68 function msds_loop($letter=false) { 65 global $wp_admin_bar, $wpdb;69 global $wp_admin_bar,$wpdb; 66 70 67 71 // add letter menu … … 72 76 73 77 // query sites 74 $blogs = $wpdb->get_results("SELECT domain, path FROM $wpdb->blogs".(($letter) ? " WHERE UPPER(LEFT(REPLACE(path,'/',''), 1) = '$letter')" : "")." ORDER BY path",ARRAY_A);75 78 $blogs = $wpdb->get_results("SELECT domain, path,".((SUBDOMAIN_INSTALL) ? "domain" : "REPLACE(path,'/','')")." AS bname FROM $wpdb->blogs WHERE blog_id != 1".(($letter) ? " AND UPPER(LEFT(".((SUBDOMAIN_INSTALL) ? "domain" : "REPLACE(path,'/','')").", 1) = '$letter')" : "")." ORDER BY path",ARRAY_A); 79 76 80 // add menu item for each site 77 81 $i = 1; 78 82 foreach($blogs as $b) { 79 $url = 'http://'.$b['domain'].$b['path'].'wp-admin';80 $wp_admin_bar->add_menu(array('parent'=>$site_parent,'id'=>'msds_'.$letter.$i,'title'=> str_replace('/','',$b['path']),'href'=>$url));83 $url = (($_SERVER['HTTPS']=="on") ? "https://" : "http://").$b['domain'].$b['path'].'wp-admin'; 84 $wp_admin_bar->add_menu(array('parent'=>$site_parent,'id'=>'msds_'.$letter.$i,'title'=>$b['bname'],'href'=>$url)); 81 85 msds_pages('site',$letter.$i,$url); 82 86 $i++; … … 85 89 86 90 function msds() { 87 if (!is_multisite() || !is_super_admin() || !is_admin_bar_showing()) return;88 global $wp_admin_bar, $wpdb,$current_blog;89 $domain = "http://".parse_url(get_bloginfo('url'),PHP_URL_HOST);90 91 if(!is_multisite() || !is_super_admin() || !is_admin_bar_showing()) return; 92 global $wp_admin_bar,$wpdb,$current_blog; 93 $domain = (($_SERVER['HTTPS']=="on") ? "https://" : "http://").DOMAIN_CURRENT_SITE; 94 91 95 // current site path 92 96 if(isset($current_blog->path) && $current_blog->path != "") { … … 94 98 $temp = "Network"; 95 99 } else { 96 if($current_blog->path != "/") $temp = str_replace('/','',$current_blog->path); 97 else $temp = "Root Site"; 100 if($current_blog->blog_id == 1) $temp = "Root Site"; 101 else { 102 if(SUBDOMAIN_INSTALL) $temp = $current_blog->domain; 103 else $temp = str_replace('/','',$current_blog->path); 104 } 98 105 } 99 106 $current = "<span style='margin-left:8px;padding:4px;background-color:yellow;color:#000;font-weight:bold;text-shadow:none;'>".$temp."</span>"; … … 115 122 if(get_site_option('msds_group')=="alpha") { 116 123 // get alphabet 117 $alpha = $wpdb->get_results("SELECT DISTINCT UPPER(LEFT( REPLACE(path,'/',''), 1)) AS first_letter FROM $wpdb->blogs WHERE blog_id != 1 ORDER BY first_letter",ARRAY_A);124 $alpha = $wpdb->get_results("SELECT DISTINCT UPPER(LEFT(".((SUBDOMAIN_INSTALL) ? "domain" : "REPLACE(path,'/','')").", 1)) AS first_letter FROM $wpdb->blogs WHERE blog_id != 1 ORDER BY first_letter",ARRAY_A); 118 125 119 126 // call main loop for each letter -
multisite-dashboard-switcher/trunk/readme.txt
r458702 r459721 4 4 Requires at least: 3.2.1 5 5 Tested up to: 3.2.1 6 Stable tag: 1. 06 Stable tag: 1.1 7 7 8 8 == Description == … … 30 30 == Changelog == 31 31 32 = 1.1 = 33 November 5, 2011 34 * Fixed: Subdomain multisites 35 * Added: Visit link for each site, HTTPS persistence on links 36 32 37 = 1.0 = 38 November 2, 2011 33 39 * First version released
Note: See TracChangeset
for help on using the changeset viewer.