WordPress Plugin: Site Help

20090215690

WordPress sites that are more that are more than just a blog often require some documentation showing what parts of the site are dynamic, how to update a sidebar section or change a contact page. The most convenient place for this documentation: inside the WordPress admin. Perhaps more of a tip than a plugin, this method uses the WordPress plugin architecture but beyond that it’s really just a chunk of custom HTML content.

Adding items to admin menu

Menu items can be added registering an add_menu_page function with the admin_menu hook. Its parameters allow for customizing the content and functionality of the menu item:


add_menu_page(page_title, menu_title, access_level/capability, file, [function], [icon_url]);

WordPress uses a default icon if one isn’t specified. ‘/favicon.ico’ also works nice.

Saving the help content

Extra simple. The help content could be stored in the database, a separate file or echoed from the plugin. Database storage requires a more complex plugin. A separate HTML file would bypass the built in WordPress authentication and become accessible to anyone that knows the document URL. Escaping quotes in echo statements can be messy. Enter PHP’s heredoc.

Storing all the help content as HTML within a heredoc statement prevents having to escape any quotes in the string. In the plugin, the heredoc statement opens with a few CSS rules to better format the page’s headers and lists along with a div with class="wrap" to preserve some default WordPress formatting. Beyond that, it’s whatever HTML you need to document how the site works.

That’s it. A quick way to securely document how a WordPress site works that will always be available to authorized users. For more complex cases, sub menus can also be created.

Download a template of the plugin.

Comments

  1. matches 20090216

    Holy hell! This looks epic!

    You should look into developing a WPMU version as well. I suspect this will plug in nicely as-is, but MU adds some additional menus.

    That said, I’ll give this ago on my test MU install and see how it goes.

  2. matches 20090216

    Okay so maybe I misunderstood. Still, I look forward to messing with this.

  3. waytoocrowded 20090216

    Yeah. “Epic” seems like a reasonable description only is if it is drenched in sarcasm or from misrepresentation.

    That said, I would assume it should play fine with MU as I believe it uses most of the same hooks.

  4. sally 20090217

    ahhhh… ummmm… what?

  5. matches 20090218

    For sure. I haven’t had a chance to look at it yet, but it seems like a logical little addition.

  6. sally 20090219

    yeah okay… logical! make fun of me more.


Skateboards and bikes are better at nights

Skateboards and bikes are better at nights. 0 comments.


Search WayTooCrowded
The Header Should Always Point Home