Code Snippets

WordPress Snippets

Hooks, filters, and getting out of the theme editor - shortcodes, functions.php snippets, and how to write them without opening a hole.

Four WordPress notes: two on shortcodes, one on debugging and one on project management inside the admin.

Including a PHP file from a shortcode shows the fix for a local file inclusion hole in the 2014 version. A shortcode that lists posts or pages is the version meant to keep working through upgrades. Turning on debugging is one line in the active child theme's functions.php. CollabPress puts project management inside WordPress.

Everything in WordPress Snippets

  • Diagram: the WordPress admin frame with Tasks, Milestones and Calendar panels added inside it, replacing a separate project-management app.

    08/06/2014

    CollabPress: project management inside WordPress

    Some people are so enamored with these shiny new project management tools that load so nicely on our smart phones that they forget it should be a transparent part of the project and not a task and part of the process of…

  • Diagram: a shortcode with category and limit arguments feeding a list of post cards, each carrying a thumbnail and an excerpt.

    03/08/2014

    A WordPress shortcode that lists posts or pages

    In WordPress, you can do a lot with shortcodes, the problem is, some work fine then one day they just break. It’s best to stick with ones that work reliably, even when you upgrade.

  • Insert PHP Code in WordPress via Shortcode

    02/26/2014

    Including a PHP file from a WordPress shortcode, safely

    The 2014 version of this shortcode takes a file path out of the post and includes it, which is a local file inclusion hole with extra steps. The fix is small: let the code decide which files are includable, not the person writing the post.

  • Diagram: the three WordPress debug constants and the combination that is safe to leave on for a live site.

    02/26/2014

    Turn on WordPress Debugging

    When you’re in development mode, it’s useful to get errors in scripts as they occur. Just place this line anywhere in your functions.php file for your active child theme and you will start seeing debug feedback complete…