Plugin Directory

Changeset 459721


Ignore:
Timestamp:
11/05/2011 07:01:05 PM (14 years ago)
Author:
sjlevy
Message:

Version 1.1 release

Location:
multisite-dashboard-switcher/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • multisite-dashboard-switcher/trunk/multisite-dashboard-switcher.php

    r458665 r459721  
    33    Plugin Name: Multisite Dashboard Switcher
    44    Plugin URI: http://samjlevy.com/msds
    5     Description: Adds a menu to the Admin Bar for easy switching between Multisite dashboards.
    6     Version: 1.0
     5    Description: Adds a menu to the admin bar for easy switching between multisite dashboards.
     6    Version: 1.1
    77    Author: Sam J Levy
    88    Author URI: http://samjlevy.com/
    99*/
    1010?><?php
    11 /*  Copyright 2011  Sam J Levy  (email : sam@samjlevy.com)
     11/*
     12    Copyright 2011  Sam J Levy  (email : sam@samjlevy.com)
    1213
    13     This program is free software; you can redistribute it and/or modify
    14     it under the terms of the GNU General Public License, version 2, as
    15     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.
    1617
    17     This program is distributed in the hope that it will be useful,
    18     but WITHOUT ANY WARRANTY; without even the implied warranty of
    19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20     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.
    2122
    22     You should have received a copy of the GNU General Public License
    23     along with this program; if not, write to the Free Software
    24     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     23    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
    2526*/
    2627?><?php
    2728add_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');
     29add_action('network_admin_menu','msds_settings_menu');
     30add_action('admin_post_update_my_settings','msds_settings_save');
    3031register_uninstall_hook(__FILE__,'msds_uninstall');
    3132
    32 function msds_init() {
    33     add_submenu_page('settings.php','Multisite Dashboard Switcher Options','Multisite Dashboard Switcher','manage_network_options','msds-options','msds_options');
     33function msds_settings_menu() {
     34    add_submenu_page('settings.php','Multisite Dashboard Switcher Options','Multisite Dashboard Switcher','manage_network_settings','msds-options','msds_settings');
    3435}
    3536
    36 function msds_options() {
     37function msds_settings() {
    3738    $msds_group = get_site_option('msds_group');
    3839    echo "<h2>Multisite Dashboard Switcher - Options</h2>";
     
    4546}
    4647
    47 function msds_options_save() {
     48function msds_settings_save() {
    4849    check_admin_referer('msds_nonce');
    49     if(!current_user_can('manage_network_options')) return;
     50    if(!current_user_can('manage_network_settings')) return;
    5051    if(isset($_POST['msds_group'])) update_site_option('msds_group', 'alpha');
    5152    else delete_site_option('msds_group');
     
    5657function msds_pages($type,$id,$url) {
    5758    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');
    5960    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');
    6061    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    }
    6266}
    6367
    6468function msds_loop($letter=false) {
    65     global $wp_admin_bar, $wpdb;
     69    global $wp_admin_bar,$wpdb;
    6670
    6771    // add letter menu
     
    7276
    7377    // 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   
    7680    // add menu item for each site
    7781    $i = 1;
    7882    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));
    8185        msds_pages('site',$letter.$i,$url);
    8286        $i++;
     
    8589
    8690function 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   
    9195    // current site path
    9296    if(isset($current_blog->path) && $current_blog->path != "") {
     
    9498            $temp = "Network";
    9599        } 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            }
    98105        }
    99106        $current = "<span style='margin-left:8px;padding:4px;background-color:yellow;color:#000;font-weight:bold;text-shadow:none;'>".$temp."</span>";
     
    115122    if(get_site_option('msds_group')=="alpha") {
    116123        // 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);
    118125       
    119126        // call main loop for each letter
  • multisite-dashboard-switcher/trunk/readme.txt

    r458702 r459721  
    44Requires at least: 3.2.1
    55Tested up to: 3.2.1
    6 Stable tag: 1.0
     6Stable tag: 1.1
    77
    88== Description ==
     
    3030== Changelog ==
    3131
     32= 1.1 =
     33November 5, 2011
     34* Fixed: Subdomain multisites
     35* Added: Visit link for each site, HTTPS persistence on links
     36
    3237= 1.0 =
     38November 2, 2011
    3339* First version released
Note: See TracChangeset for help on using the changeset viewer.