I've got a wordpress website. I'm writing a wordpress plugin for wordpress where I wish to make use of the codeigniter framework inside the wordpress plugin. I'm getting challenge with this since the codeigniter bootstrap file "index.php" needs to become run within the global scope, not inside a function.

at this time, inside my wordpress plugin, I actually do the next:

// BEGIN: wordpress plugin code

function classifieds_template_redirect()


  $wordpress plugin_path = wordpress plugin_dir_path(__FILE__)

  if (preg_match('/^CI/', $wordpress->request))  // use codeigniter to handle request

  wordpress plugin_path."/index.php"  // range from the codeigniter bootstrap file



add_action( 'template_redirect', 'classifieds_template_redirect' )

// Finish: wordpress plugin code

The next error has been 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

In my opinion this really is because of CodeIgniter expecting its bootstrap index.php file to become run in global scope.

Any Ideas?

Listed here are your choices:

  1. Rewrite web addresses (making use of your webserver) which begins having a certain identifier to obtain delivered to Code igniters bootstrap
  2. Rewrite CI's routing boiler plate to sit in not tell you bootstrap over global scope
  3. Make use of a small mvc wordpress plugin in Wordpress rather than CI

I will cover the first because I believe it helps make the most sense if you are planning to become persistent about adhering with CI. And I will provide you with some evidence of concept code using Apache as webserver and mod_rewrite to do this.

Essentially all we'll achieve is the code you've proven us but rather we'll make apache get it done for all of us making CI being run climax bootstrap over global scope.

Whatever you do would be to increase the rules towards the wordpress .htaccess-file. Such as this:

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /

        #Here's the code which rewrites the url to your CI plugin. 
        RewriteRule ^CI/(?.*)$ wp-content/plugins/ci-plugin/index.php/$1 [QSA,L]

        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]


Now all request to www.example.com/CI/... is going to be passed to CI's bootstrap over global scope.