• Resolved ohildner

    (@ohildner)


    Hi, I’m trying to write a plugin where it is possible to write PHP-Code (eg. Shortcodes) in the Admin-Area.
    I was wondering how WordPress prechecks the Code in the Theme and Plugin Editor and doesn’t save the file if it would create an error.
    I’d like to use that too.

    I already read through ‘wp-includes/error-protection.php’ and the ‘WP_Error Class’ but I’m totally not sure if I’m on the right track here.

    • This topic was modified 5 years, 11 months ago by Jan Dembowski.
Viewing 4 replies - 1 through 4 (of 4 total)
  • No, that is not the right code to look at.
    The file editors use CodeMirror to show the errors as the file is edited, but during the save process, a loopback mechanism is used to load WP with the changes to see if an error is thrown. If it is, the original file is put back.
    The same loopback is used in some of the Site Health checks.

    Thread Starter ohildner

    (@ohildner)

    Thank you for your answer.

    Do you know where the code is located?

    Or do you have an idea how to use this method to check custom files as I described?

    Thread Starter ohildner

    (@ohildner)

    Thank you. I’ll check on that.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How does WP Precheck for PHP Errors in Code Editors’ is closed to new replies.