• Fatal error: require_once() [function.require]: Failed opening required ‘TEMPLATEPATH/…

    I got this error message unexpectedly while running the Launch Effect theme on a otherwise default WordPress installation every time I tried to submit the contact form.

    Now I would have blamed the theme, but tried to trace the error. Going through the code file by file with a die('here') I finally ended up on lines 198-200 in wp-settings.php:

    foreach ( wp_get_active_and_valid_plugins() as $plugin )
      	include_once( $plugin );
    unset( $plugin );

    Trying to make sure this was the line causing the error, I put a simple echo('here'); before and after the block. Turns out the first is displayed, the second not.

    So, to investigate which plugin broke the blog, I added a line for debug output:

    foreach ( wp_get_active_and_valid_plugins() as $plugin )
            print($plugin);
      	include_once( $plugin );
    unset( $plugin );

    Much to my surprise, the file now worked. The fatal error was gone. So, in an attempt of utter irritation, I re-wrote the line to this:

    foreach ( wp_get_active_and_valid_plugins() as $plugin )
        (function(){});
    	include_once( $plugin );
    unset( $plugin );

    … and now everything works just fine.

    Does anyone have any idea what the heck is going on here? I am very, very confused ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p

    (@t-p)

    What happens when you switch to the WP default theme?

    First, wp-settings.php is not your problem, that’s a WordPress core file, and not one you should change.

    To answer your question…

    foreach ( wp_get_active_and_valid_plugins() as $plugin )
            print($plugin);
      	include_once( $plugin );
    unset( $plugin );

    does not do what you think it does…

    foreach doesn’t require a curly bracket if there is only one statement, but does if there are multiple statements.

    So your update above, is the same as if you had written it this way:

    foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
            print($plugin);
    }
    include_once( $plugin );
    unset( $plugin );

    So it printed every plugin, but only included the last one. (assuming there were more than one active plugins)

    Your second bit of modified code:

    foreach ( wp_get_active_and_valid_plugins() as $plugin )
        (function(){});
    	include_once( $plugin );
    unset( $plugin );

    basically did the same thing, but without printing anything. (it just included the last active plugin)

    Thread Starter chknoflach

    (@chknoflach)

    Scriptrunner, thanks a million.

    What a stupid mistake ??

    Happens to the best of us. Mistakes are are a great way to learn ??

    I guess I didn’t completely answer your question, though I assume you may have deduced it. Since you were only loading that last active plugin in the foreach loop, all the others were not, so basically all the other plugins were essentially disabled, and that must have included the one that was causing the original error.

    Good luck and happy coding!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘500 Server Error, TEMPLATEPATH not defined and a VERY weird fix’ is closed to new replies.