Internal Post Management in Crayon

Crayon’s internal post management determines when the rest of the system should kick in.

When you save/edit a page, Crayon searches through the content and keeps a reference to the post in the database if it contains any Crayon tags. When you save/edit a comment, the same process takes place.

When you load a page, Crayon goes through all the posts requested (for a single page, this is usually just a single post) and only checks those known to contain Crayon posts. For each of these, Crayon captures any tags used and keeps them in internal PHP memory.

When the page or comment content is requested by WordPress, Crayon steps in, highlights the code in the tags it captured earlier and replaces the original tags in the content.

This means that only those pages that contain Crayons are ever checked for Crayons, meaning much more efficient than looking through every single post on the blog for Crayon tags!

In Crayon 1.12, I’ve added a feature in the settings page to display all the posts that contain Crayon tags. It will also list all the posts which have Crayon tags in their comments, even if the post itself doesn’t contain any. This is crucial to ensure Crayon kicks in and highlights the code in those comments.

As an added safety measure, when you refresh the settings page, Crayon will manually go through all the posts in your site and update the list of those containing Crayons in the database. So if anything funky happens that somehow messes up this list, refreshing the settings page should sort it out.

  • rhempel

    Aram – Crayon is working great for me except that I cannot use it on a particular part of my site due to this Internal Post Management feature. Some of my static pages describe APIs for my product, like this:

    EXAMPLE_START->
    The General API is for functions that don’t fit neatly into a category big enough to make a separate section. It includes functions to control the NXT power, read the buttons and timers, and other miscellaneous operations.

    [hdg_expandFile name="#functionDefs/misc/ButtonRead.txt" ]
    [hdg_expandFile name="#functionDefs/misc/TimerRead.txt" ]
    [hdg_expandFile name="#functionDefs/misc/BatteryRead.txt"]
    <-EXAMPLE_END

    The [hdg_expand_file] shortcode grabs the content of the specified file and expands the content into the current page.

    If there is a Crayon in the page I am expanding, it never get processed because Crayon only looks for crayons in the raw content and comments.

    Would it be possible to add an option to process the page before checking for crayons?

    Or to add a table of pages that are "forced to have crayons?

    Cheers, Ralph