Not finding Theme path when using eval() code

All,
I’m using the following code to try and set an include path for my WordPress page:

$themePath = trailingslashit(get_bloginfo('template_url'));
set_include_path($themePath);
include_once 'Zend/Loader.php';

This works fine if I don’t use it from within an actual Page in WordPress. I’m using the Exec-PHP plugin to display my PHP. When I put this in that code it doesn’t understand the include path and gives me an error that my Zend/Loader file couldn’t be found.

Read More

The error message I receive is:

Fatal error: Class ‘Zend_Loader’ not found in D:My Documentsxampphtdocswordpresswp-contentpluginsexec-phpincludesruntime.php(42) : eval()’d code on line 31

The Zend loader is in the following path:
http://localhost/vendor_wordpress/wp-content/themes/themename/

Any idea on how to set the include path and use the Exec-PHP to process my PHP code?

Related posts

Leave a Reply

1 comment

  1. You are using template_url for includes which gives you URL and not absolute path, which should be used for includes.

    What you should use instead is

    $themePath = ABSPATH . 'wp-content/themes/themename';
    

    and you should preserve the original include path as well:

    set_include_path(get_include_path() . PATH_SEPARATOR . $themePath );