• Can you please add to your documentation on this site when this runs in relation to functions.php?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sgumby

    (@sgumby)

    Sorry….followup. How does this handle errors that would normally cause php to crash?

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @sgumby,

    I’ve added a page to our help documentation that explains where snippets are executed in the WordPress load order. Please let us know if you’d like more detail to be added or something is missing from the article.

    In relation to error avoidance, there are a few stages. The first is a live linter that checks your PHP code as you write it in the editor. This uses a library to do general PHP syntax checking, while also checking that there are no duplicated classes or functions within the snippet.

    When you save a snippet, a second set of validation is run, where the code is broken into tokens, allowing for some basic syntax checking, and then the result is once more checked for duplicate identifiers. The important differentiator in this step from the first one is that the new functions and classes can be checked against those already existent on the site from WordPress core, themes, and other plugins.

    Finally, the snippet code is then evaluated before it is saved to the database. This ensures that buggy code is not permanently saved and any errors can be recovered from.

    In the odd case when a buggy snippet is active on your site, Code Snippets includes a built-in safe mode feature to temporarily halt all snippets from running, allowing you to access your site and manually fix the problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘When does snippets run’ is closed to new replies.