PluginProbe
Plugins List / 2.0
Plugins List v2.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 2.0, at plugins-list.php

134 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Artiss Plugins List
4 Plugin URI: http://www.artiss.co.uk/plugins-list
5 Description: Displays a list of the active plugins
6 Version: 2.0
7 Author: David Artiss
8 Author URI: http://www.artiss.co.uk
9 */
10
11 /**
12 * Plugins List
13 *
14 * Generate list of plugins
15 *
16 * @package Artiss-Plugins-List
17 */
18
19 define( APL_DEFAULT_PLUGIN_FORMAT, "<li><a href='#PluginURI#' title='#Title#'>#Title#</a> by <a href='#AuthorURI#' title='#Author#']}'>#Author#</a>.</li>" );
20
21 if ( !function_exists( 'get_plugins' ) ) { require_once ( ABSPATH . 'wp-admin/includes/plugin.php' ); }
22
23 /**
24 * Add meta to plugin details
25 *
26 * Add options to plugin meta line
27 *
28 * @since 2.0
29 *
30 * @param string $links Current links
31 * @param string $file File in use
32 * @return string Links, now with settings added
33 */
34
35 function apl_set_plugin_meta( $links, $file ) {
36
37 if ( strpos( $file, 'plugins-list.php' ) !== false ) {
38 $links = array_merge( $links, array( '<a href="http://www.artiss.co.uk/forum">' . __( 'Support' ) . '</a>' ) );
39 $links = array_merge( $links, array( '<a href="http://www.artiss.co.uk/donate">' . __( 'Donate' ) . '</a>' ) );
40 }
41
42 return $links;
43 }
44 add_filter( 'plugin_row_meta', 'apl_set_plugin_meta', 10, 2 );
45
46 /**
47 * Main Shortcode Function
48 *
49 * Extract shortcode parameters and call main function to output results
50 *
51 * @since 1.0
52 *
53 * @uses get_plugins_list Get the list of plugins
54 *
55 * @param string $paras Shortcode parameters
56 * @return string Output
57 */
58
59 function apl_plugins_list_shortcode( $paras ) {
60
61 extract( shortcode_atts( array( 'format' => APL_DEFAULT_PLUGIN_FORMAT, 'show_inactive' => false ), $paras ) );
62
63 $output = get_plugins_list( $format, $show_inactive );
64
65 return $output;
66 }
67 add_shortcode( 'plugins_list', 'apl_plugins_list_shortcode' );
68
69 /**
70 * Get Plugins List
71 *
72 * Get list of plugins and, optionally, format them
73 *
74 * @since 1.0
75 *
76 * @uses apl_format_plugin_list Format the plugin list
77 *
78 * @param string $format Requires format
79 * @param string $show_inactive Whether to format or not
80 * @return string Output
81 */
82
83 function get_plugins_list( $format = APL_DEFAULT_PLUGIN_FORMAT, $show_inactive = false ) {
84 $plugins = get_plugins();
85 $output = '';
86 foreach( $plugins as $plugin_file => $plugin_data ) {
87 if ( $show_inactive || is_plugin_active( $plugin_file ) ) { $output .= apl_format_plugin_list( $plugin_data, $format ); }
88 }
89 return $output;
90 }
91
92 /**
93 * Format Plugin List
94 *
95 * Format the plugin list
96 *
97 * @since 1.0
98 *
99 * @param string $plugin_data The plugin list
100 * @param string $format Format to use
101 * @return string Output
102 */
103
104 function apl_format_plugin_list( $plugin_data, $format ) {
105
106 // Allowed tag
107
108 $plugins_allowedtags1 = array( 'a' => array( 'href' => array(), 'title' => array() ), 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), 'code' => array(), 'em' => array(), 'strong' => array() );
109
110 $plugins_allowedtags2 = array( 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), 'code' => array(), 'em' => array(), 'strong' => array() );
111
112 // Sanitize all displayed data
113
114 $plugin_data[ 'Title' ] = wp_kses( $plugin_data[ 'Title' ], $plugins_allowedtags1 );
115 $plugin_data[ 'PluginURI' ] = wp_kses( $plugin_data[ 'PluginURI' ], $plugins_allowedtags1 );
116 $plugin_data[ 'AuthorURI' ] = wp_kses( $plugin_data[ 'AuthorURI' ], $plugins_allowedtags1 );
117 $plugin_data[ 'Version' ] = wp_kses( $plugin_data[ 'Version' ], $plugins_allowedtags1 );
118 $plugin_data[ 'Author' ] = wp_kses( $plugin_data[ 'Author' ], $plugins_allowedtags1 );
119
120 // Replace the tags
121
122 $format = str_replace( '#Title#', $plugin_data[ 'Title' ], $format );
123 $format = str_replace( '#PluginURI#', $plugin_data[ 'PluginURI' ], $format );
124 $format = str_replace( '#AuthorURI#', $plugin_data[ 'AuthorURI' ], $format );
125 $format = str_replace( '#Version#', $plugin_data[ 'Version' ], $format );
126 $format = str_replace( '#Description#', $plugin_data[ 'Description' ], $format );
127 $format = str_replace( '#Author#', $plugin_data[ 'Author' ], $format );
128
129 $format = str_replace( '#LinkedTitle#', "<a href='" . $plugin_data[ 'PluginURI' ] . "' title='" . $plugin_data[ 'Title' ] . "'>" . $plugin_data[ 'Title' ] . "</a>", $format );
130 $format = str_replace( '#LinkedAuthor#', "<a href='" . $plugin_data[ 'AuthorURI' ] . "' title='" . $plugin_data[ 'Author' ] . "'>" . $plugin_data[ 'Author' ] . "</a>", $format );
131
132 return $format . "\n";
133 }
134 ?>