Show Plugins in Your Sidebar
Now, to make this thing show up in my sidebar instead of in the footer, we don’t need a great deal of modification. Step one is to go to modify the plugin in your Plugins → Plugin Editor panel. When you select the Show Plugins plugin, the source will come up in a textarea and you can make changes to the plugin’s code. Simple enough, so what’ve we got? At the very bottom, you’ll notice this:
// Use object to avoid namespace collisions
$show_plugins = new Show_Plugins();
// We want to modify the meta section
add_action('wp_footer', array(&$show_plugins, 'wp_footer'));
// There is no action hook for "start of processing",
// so we use this implicitly.
$show_plugins->start();
The problem, obviously, is that it’s running this plugin in the footer. We don’t need any of the above code, so delete it. The start() function is empty, as you may have noticed, so we won’t be needing that, either. Delete it, too. Now we’re left with two functions, wp_footer() and get_plugin_data(). Rename wp_footer() to start() to avoid any possible compatibility issues (though I doubt it would be a problem, since this function is run within a class and is therefore a private function as opposed to a public one).
Now let’s make some changes to the start() function (which we renamed from wp_footer()). The end of the function is where an echo statement is, indicating HTML output. However, we want an unordered list… Right? (If not, skip this part.) Take a look at the following code.
echo("<div class=\"show-plugins\">" .
__("Plugins: ") .
join(', ', $plugins) . "</div>");
Change the above to something more elegant, like what I’ve done below. (Note that I’m referring to the output rather than the actual PHP code when I suggest that the solution is more elegant.)
echo(' <ul class="show-plugins">'."\n".' <li>'.
join('</li>'."\n".' <li>', $plugins).
' </ul>'."\n");
You’re done modifying the plugin! Save that bugger, and go to the Presentation → Theme Editor panel. Make sure you’re modifying the correct theme (the one your site’s using, or more than one if you have a theme-switcher) and locate the file you use for your sidebar to edit it (in the default theme, Kubrick, I believe the file is named “sidebar.php”). Decide where you want this list to appear, and place the following code in that place.
<?php
$show_plugins = new Show_Plugins();
$show_plugins->start();
?>
All the above does is creates a new Show_Plugins class and calls the start() function to output the HTML we want. You can use any kind of list in any kind of format. I did exactly what I showed in this blog entry (in the sidebar, I added an H3 that says “Wordpress Plugins”), so it should work for any Wordpress blog running WP 1.5 or greater. Hope this helps some of you folks out there!
Fan-freakin’-tastic! Took me no time to make the changes.
Any advice you can give me on entering and modifying a style entry in my css sheet? I am pretty stupid when it comes to this stuff. You can see how it looks on my site. The spaces between all of the plugins bothers me.
Any help would be appreciated.
Thanks!
June 18th, 2005 at 11:54 am
Nevermind…I fixed it. Thanks! This version of the plugin rocks!
June 18th, 2005 at 2:04 pm
I’m glad it helped you.
June 18th, 2005 at 7:27 pm
[...] Solución : gracias al comentario encontrado en Slightly Remarkable y haciéndolo con paciencia se puede poner en cualquier sitio. Está en inglés pero si se sigue paso a paso se consigue fácilmente. [...]
November 15th, 2005 at 9:06 am