PluginProbe
Plugins List / 1.0
Plugins List v1.0
trunk 0.2.1 0.2.2 1.0 2.0 2.1 2.2.7 2.3.2 2.4.4 2.5.2 2.6 2.6.1 2.7
plugins-list / plugins-list.php

plugins-list.php in Plugins List 1.0, at plugins-list.php

83 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Plugins list
4 Plugin URI: http://davidebenini.it/wordpress-plugins/plugins-list/
5 Description: Displays a list of the active plugins - just insert [plugins_list] in posts or pages, between ul or ol elements. If you want more custimization, take a look at the <a href='http://davidebenini.it /wordpress-plugins/plugins-list' title='Plugins list documentation'>documentation</a>.
6
7 Version: 1.0
8 Author: Davide Benini
9 Author URI: http://www.davidebenini.it/
10 */
11 /* Copyright 2008 Davide Benini (email : benini.davide@gmail.com)
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
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.
22
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
26 */
27
28
29 define(DBENINI_DEFAULT_PLUGIN_FORMAT, "<li><a href='#PluginURI#' title='#Title#'>#Title#</a> (v. #Version#) by <a href='#AuthorURI#' title='#Author#']}'>#Author#</a>.</li>");
30
31
32 if (!function_exists('get_plugins'))
33 require_once (ABSPATH."wp-admin/includes/plugin.php");
34
35 add_shortcode('plugins_list', 'plugins_list_func');
36 function plugins_list_func($atts) {
37 extract(shortcode_atts(array(
38 'format' => DBENINI_DEFAULT_PLUGIN_FORMAT,
39 'show_inactive' => false,
40 ), $atts));
41 $list = dbenini_plugins_list($format, $show_inactive);
42 return $list;
43 }
44
45 function dbenini_plugins_list($format = DBENINI_DEFAULT_PLUGIN_FORMAT, $show_inactive = false ) {
46 $plugins = get_plugins ();
47 $output = "";
48 foreach($plugins as $plugin_file => $plugin_data) {
49 if ($show_inactive || is_plugin_active($plugin_file))
50 $output .= dbenini_plugin_with_format($plugin_data, $format);
51 }
52
53 return $output;
54 }
55
56
57 function dbenini_plugin_with_format($plugin_data, $format) {
58
59 // Alloweed tag
60 $plugins_allowedtags1 = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
61 $plugins_allowedtags2 = array('abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
62
63 // Sanitize all displayed data
64 $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags1);
65 $plugin_data['PluginURI'] = wp_kses($plugin_data['PluginURI'], $plugins_allowedtags1);
66 $plugin_data['AuthorURI'] = wp_kses($plugin_data['AuthorURI'], $plugins_allowedtags1);
67 $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags1);
68 //$plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags2);
69 $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags1);
70 //$plugin_data['Description'] = preg_replace ("@<a .*?".">(.*?)</a>@mis", "\\1", $plugin_data['Description']);
71
72
73 $format = str_replace("#Title#", $plugin_data['Title'], $format);
74 $format = str_replace("#PluginURI#", $plugin_data['PluginURI'], $format);
75 $format = str_replace("#AuthorURI#", $plugin_data['AuthorURI'], $format);
76 $format = str_replace("#Version#", $plugin_data['Version'], $format);
77 $format = str_replace("#Description#", $plugin_data['Description'], $format);
78 $format = str_replace("#Author#", $plugin_data['Author'], $format);
79 $format = str_replace("#LinkedTitle#", "<a href='".$plugin_data['PluginURI']."' title='".$plugin_data['Title']."'>".$plugin_data['Title']."</a>", $format);
80 $format = str_replace("#LinkedAuthor#", "<a href='".$plugin_data['AuthorURI']."' title='".$plugin_data['Author']."'>".$plugin_data['Author']."</a>", $format);
81 return $format;
82 }
83 ?>