Markdown Menu Snippet

On a recent project I found it useful to be able to add a README page to the administration.  This became a convenient location to document some things for both the client and other developers. Additionally, the benefit of actually having a Markdown file in the theme allowed for version control. Maybe this will get extrapolated into a plugin to allow for a GUI and arbitrary number of Markdown menus; in the meantime, this is all that was involved:

<!-- MENU.md -->
## Markdown Menu Demonstration

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed est felis, pulvinar vitae pretium at, tempor eu augue. Phasellus libero sem, commodo ut enim ut, vehicula euismod risus.

### Troubleshooting Steps

1. Find a problem
2. Confirm the problem
3. Fix the problem

---

### How do I do this?

Probably very carefully... Otherwise proin vulputate, odio in gravida gravida, lorem velit malesuada nibh, in pellentesque arcu enim ac libero. Maecenas porttitor eu urna id aliquam.

### Who should I talk to about training?

Usually the best person to contact is John Smith. Suspendisse ac ullamcorper ligula. Nulla facilisi. Nunc fringilla, diam in volutpat dictum, dui tortor vestibulum nisi, eget ultrices orci quam vitae turpis.

Then, tell WordPress you want to add the menu item and add a Markdown parser. In this example, I use Parsedown, but PHP Markdown is another option. Update functions.php to reflect these changes:

//functions.php
include_once 'Parsedown.php';

add_action('admin_menu', 'add_my_markdown_menu');

function add_my_markdown_menu() {
    add_dashboard_page(
        'Markdown Menu Demonstration',
        'Help &amp; Support',
        'edit_posts',
        'my_markdown_menu_slug',
        'get_my_markdown'
    );
}

function get_my_markdown() {
    if ( !current_user_can( 'edit_posts' ) ) {
        return;
    }
    echo '<div class="wrap">';

    $md = file_get_contents( __DIR__ . '/MENU.md' );
    $parsedown = new Parsedown();
    echo $parsedown->text( $md );

    echo '</div>';
}

Always remember: any text files within your theme (or plugin) are web accessible and, unless prevented by your web server, are directly navigable.