Make WordPress Core

Ticket #3047: get_plugininfo.php

File get_plugininfo.php, 1.4 KB (added by forceagainstsomething, 20 years ago)
Line 
1<?php
2function get_plugininfo($info, $plugin_filename) {
3        global $wp_active_plugins;
4       
5        $plugin_filename = str_replace('\\', '/', $plugin_filename);
6        if (!preg_match('@wp-content/plugins/(.*)/@U', $plugin_filename, $matches)) { 
7                $plugin_base = basename($plugin_filename); 
8        } else { 
9                $plugin_base = $matches[1]; 
10        }
11
12        $plugin_filename = null;
13        foreach($wp_active_plugins as $plugin_name => $plugin_data) {
14                if (substr($plugin_name, 0, strlen($plugin_base)) == $plugin_base) {
15                        $plugin_filename = $plugin_name;
16                        break;
17                }
18        }
19
20        if ($plugin_filename == null || !isset($wp_active_plugins[plugin_basename($plugin_filename)])) {
21                return '';
22        }
23       
24        switch($info) {
25                case 'url':
26                        return $wp_active_plugins[$plugin_filename]['URL'];
27                        break;
28                case 'version':
29                        return $wp_active_plugins[$plugin_filename]['Version'];
30                        break;
31                case 'path':
32                        return $wp_active_plugins[$plugin_filename]['Path'];
33                        break;
34                case 'name':
35                        return $wp_active_plugins[$plugin_filename]['Name'];
36                        break;
37                case 'title':
38                        return $wp_active_plugins[$plugin_filename]['Title'];
39                        break;
40                case 'description':
41                        return $wp_active_plugins[$plugin_filename]['Description'];
42                        break;
43                case 'author':
44                        return $wp_active_plugins[$plugin_filename]['Author'];
45                        break;
46                case 'authoruri':
47                        return $wp_active_plugins[$plugin_filename]['AuthorURI'];
48                        break;
49                case 'pluginuri':
50                        return $wp_active_plugins[$plugin_filename]['PluginURI'];
51                        break;
52        }
53?>