Make WordPress Core

Changeset 1894


Ignore:
Timestamp:
11/28/2004 12:33:04 AM (22 years ago)
Author:
rboren
Message:

Allow plugins to be loaded from subdirs of wp-content/plugins.

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r1887 r1894  
    733733}
    734734
     735function plugin_basename($file) {
     736        return preg_replace('#^.*wp-content/plugins/#', '', $file);
     737}
     738
    735739function add_menu_page($page_title, $menu_title, $access_level, $file) {
    736740        global $menu;
    737741
    738         $file = basename($file);
     742        $file = plugin_basename($file);
    739743
    740744        $menu[] = array($menu_title, $access_level, $file, $page_title);
     
    744748        global $submenu;
    745749
    746         $file = basename($file);
     750        $file = plugin_basename($file);
    747751
    748752        $submenu[$parent][] = array($menu_title, $access_level, $file, $page_title);
     
    885889        if ($plugins_dir) {
    886890                while(($file = $plugins_dir->read()) !== false) {
    887                         if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
    888                                 $plugin_files[] = $file;
     891                        if ( preg_match('|^\.+$|', $file) )
     892                                continue;
     893                        if (is_dir($plugin_root . '/' . $file)) {
     894                                $plugins_subdir = @ dir($plugin_root . '/' . $file);
     895                                if ($plugins_subdir) {
     896                                        while(($subfile = $plugins_subdir->read()) !== false) {
     897                                                if ( preg_match('|^\.+$|', $subfile) )
     898                                                        continue;
     899                                                if ( preg_match('|\.php$|', $subfile) )
     900                                                        $plugin_files[] = "$file/$subfile";
     901                                        }
     902                                }
     903                        } else {
     904                                if ( preg_match('|\.php$|', $file) )
     905                                        $plugin_files[] = $file;
     906                        }
    889907                }
    890908        }
     
    903921                }
    904922
    905                 $wp_plugins[basename($plugin_file)] = $plugin_data;
     923                $wp_plugins[plugin_basename($plugin_file)] = $plugin_data;
    906924        }
    907925
  • trunk/wp-admin/admin.php

    r1818 r1894  
    5555// Handle plugin admin pages.
    5656if (isset($_GET['page'])) {
    57         $plugin_page = basename($_GET['page']);
     57        $plugin_page = plugin_basename($_GET['page']);
    5858        if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page")) {
    5959                die(sprintf(__('Cannot load %s.'), $plugin_page));
  • trunk/wp-admin/plugin-editor.php

    r1858 r1894  
    2121}
    2222
    23 $plugins_dir = @ dir(ABSPATH . 'wp-content/plugins');
    24 if ($plugins_dir) {
    25         while(($plug_file = $plugins_dir->read()) !== false) {
    26                 if ( !preg_match('|^\.+$|', $plug_file) && preg_match('|\.php$|', $plug_file) )
    27                         $plugin_files[] = "wp-content/plugins/$plug_file";
    28         }
    29 }
    30 
    31 if (count($plugin_files)) {
    32         natcasesort($plugin_files);
    33 }
    34 
    35 if (file_exists(ABSPATH . 'my-hacks.php')) {
    36         $plugin_files[] = 'my-hacks.php';
    37 }
    38 
     23$plugins = get_plugins();
     24$plugin_files = array_keys($plugins);
    3925
    4026if (empty($file)) {
     
    4329
    4430$file = validate_file_to_edit($file, $plugin_files);
    45 $real_file = get_real_file_to_edit($file);
     31$real_file = get_real_file_to_edit("wp-content/plugins/$file");
    4632
    4733switch($action) {
     
    10591  <ul>
    10692<?php foreach($plugin_files as $plugin_file) : ?>
    107                  <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo get_file_description(basename($plugin_file)); ?></a></li>
     93                 <li><a href="plugin-editor.php?file=<?php echo "$plugin_file"; ?>"><?php echo $plugins[$plugin_file]['Name']; ?></a></li>
    10894<?php endforeach; ?>
    10995  </ul>
Note: See TracChangeset for help on using the changeset viewer.