I have a WordPress website. I am writing a plugin for WordPress where I want to use the CodeIgniter framework within the plugin. I am having trouble with this because the CodeIgniter bootstrap file "index.php" expects to be run in the global scope, not within a function.
Right now, within my plugin, I do the following:
// BEGIN: plugin code
function classifieds_template_redirect()
{
global $wp;
$plugin_path = plugin_dir_path(__FILE__);
if (preg_match('/^CI/', $wp->request)) // Use CodeIgniter to handle the request
{
include($plugin_path."/index.php"; // Include the CodeIgniter bootstrap file
die();
}
}
add_action( 'template_redirect', 'classifieds_template_redirect' );
// END: plugin code
The following error is being throw:
Fatal error: Call to a member function item() on a non-object in /usr/local/apache/htdocs/site.utils/htdocs/CodeIgniter/system/core/Utf8.php on line 47
I believe this is due to CodeIgniter expecting its bootstrap index.php file to be run in global scope.
Any ideas?