Make WordPress Core

Ticket #3047: 3047a.diff

File 3047a.diff, 4.4 KB (added by westi, 20 years ago)

Replacement patch as descirbed in my comment

  • wp-includes/plugin.php

     
    165165        add_action('deactivate_' . $file, $function);
    166166}
    167167
     168
     169function get_plugin_data($plugin_file) {
     170        $plugin_data = implode('', file($plugin_file));
     171        preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name);
     172        preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);
     173        preg_match("|Description:(.*)|i", $plugin_data, $description);
     174        preg_match("|Author:(.*)|i", $plugin_data, $author_name);
     175        preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
     176        if (preg_match("|Version:(.*)|i", $plugin_data, $version))
     177                $version = trim($version[1]);
     178        else
     179                $version = '';
     180
     181        $description = wptexturize(trim($description[1]));
     182
     183        $name = $plugin_name[1];
     184        $name = trim($name);
     185        $plugin = $name;
     186        if ('' != $plugin_uri[1] && '' != $name) {
     187                $plugin = '<a href="' . trim($plugin_uri[1]) . '" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
     188        }
     189
     190        if ('' == $author_uri[1]) {
     191                $author = trim($author_name[1]);
     192        } else {
     193                $author = '<a href="' . trim($author_uri[1]) . '" title="'.__('Visit author homepage').'">' . trim($author_name[1]) . '</a>';
     194        }
     195       
     196        $dir_name = dirname($plugin_file);
     197        if ('.' == $dir_name) {
     198                $dir_name = '';
     199        }
     200
     201        $path = ABSPATH . 'wp-content/plugins' . $dir_name;
     202        $url = get_bloginfo('wpurl'). 'wp-conten/plugins' . $dir_name;
     203
     204        return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'PluginURI' => trim($plugin_uri[1]), 'AuthorURI' => trim($author_uri[1]), 'URL' => $url, 'Path' => $path);
     205}
     206
     207function get_plugininfo($info, $filename) {
     208        global $wp_active_plugins;
     209
     210        if (!isset($wp_active_plugins)) {
     211                $wp_active_plugins = array();
     212        }
     213       
     214        $plugin_filename = plugin_basename($filename);
     215
     216        if (!isset($wp_active_plugins[$plugin_filename]))
     217        {
     218                //Lazy Load the information
     219                $plugin_data = get_plugin_data($filename);
     220
     221                if (!empty($plugin_data['Name'])) {
     222                        $wp_active_plugins[$plugin_filename] = $plugin_data;
     223                } else {
     224                        return '';
     225                }
     226        }
     227
     228        switch($info) {
     229                case 'url':
     230                        return $wp_active_plugins[$plugin_filename]['URL'];
     231                        break;
     232                case 'version':
     233                        return $wp_active_plugins[$plugin_filename]['Version'];
     234                        break;
     235                case 'path':
     236                        return $wp_active_plugins[$plugin_filename]['Path'];
     237                        break;
     238                case 'name':
     239                        return $wp_active_plugins[$plugin_filename]['Name'];
     240                        break;
     241                case 'title':
     242                        return $wp_active_plugins[$plugin_filename]['Title'];
     243                        break;
     244                case 'description':
     245                        return $wp_active_plugins[$plugin_filename]['Description'];
     246                        break;
     247                case 'author':
     248                        return $wp_active_plugins[$plugin_filename]['Author'];
     249                        break;
     250                case 'authoruri':
     251                        return $wp_active_plugins[$plugin_filename]['AuthorURI'];
     252                        break;
     253                case 'pluginuri':
     254                        return $wp_active_plugins[$plugin_filename]['PluginURI'];
     255                        break;
     256        }
     257}
    168258?>
  • wp-admin/admin-functions.php

     
    16581658        update_option('recently_edited', $oldfiles);
    16591659}
    16601660
    1661 function get_plugin_data($plugin_file) {
    1662         $plugin_data = implode('', file($plugin_file));
    1663         preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name);
    1664         preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);
    1665         preg_match("|Description:(.*)|i", $plugin_data, $description);
    1666         preg_match("|Author:(.*)|i", $plugin_data, $author_name);
    1667         preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
    1668         if (preg_match("|Version:(.*)|i", $plugin_data, $version))
    1669                 $version = trim($version[1]);
    1670         else
    1671                 $version = '';
    1672 
    1673         $description = wptexturize(trim($description[1]));
    1674 
    1675         $name = $plugin_name[1];
    1676         $name = trim($name);
    1677         $plugin = $name;
    1678         if ('' != $plugin_uri[1] && '' != $name) {
    1679                 $plugin = '<a href="' . trim($plugin_uri[1]) . '" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
    1680         }
    1681 
    1682         if ('' == $author_uri[1]) {
    1683                 $author = trim($author_name[1]);
    1684         } else {
    1685                 $author = '<a href="' . trim($author_uri[1]) . '" title="'.__('Visit author homepage').'">' . trim($author_name[1]) . '</a>';
    1686         }
    1687 
    1688         return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);
    1689 }
    1690 
    16911661function get_plugins() {
    16921662        global $wp_plugins;
    16931663