• What do you suggest to quickly test a block of code before adding it to a theme file? Drupal has something called “Execute PHP Code” in the Devel module, is there something similar in WordPress? Or create a test.php file and then run php -f?test.php? Is there a “WordPress way” of doing this?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The problem with php -f test.php is it doesn’t include the WP environment. I suppose you could include /path/wp-load.php in test.php. That’ll work for your specific environment, but doing so is discouraged because it leaks into code distributed to others and it’s not entirely portable.

    For myself, I use a local installation and simply edit and test the active theme. Since WP_DEBUG is defined as true, I’ll immediately see any errors when the page is reloaded. (I also have the WP fatal error handler disabled with define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );)

Viewing 1 replies (of 1 total)
  • The topic ‘Quickly test blocks of code before adding to theme files’ is closed to new replies.