Include files for a plugin not including

I have a plugin which I need to include a file in but it doesn’t include.

Here’s the example of the tree:

Read More
plugin folder
    /themes
    /folder2
    /somefiles
    /includeme.php

Within themes is

/default
/theme2

Then within each theme are the files
E.g.

Header.php
Footer.php

The plugin simply switches these themes via the admin.

Now in header.php I added

<?php include('includeme.php'); ?>

Which didn’t work.

A friend told me since it is two levels up the tree I should actually add

<?php include('/../../includeme.php'); ?>.

Both didn’t work.

I googled something that said to try.

<?php include([$_SERVER]['DOCUMENT_ROOT']'./wp-content/plugins/plugin-name/includeme.php'); ?>.

That also didn’t work.
This is a basic plugin which renders theme based on admin settings combined with user agent detection.

Any suggestions or further code required?

The code is located at http://pastebin.com/A3buAA0R

Related posts

Leave a Reply

1 comment

  1. In your main plugin file, use plugin_dir_path to define a constant that you can then use in all of your includes. see the example on the above codex page.

    // define the constant in your main plugin file
    define( 'MYPLUGINNAME_PATH', plugin_dir_path(__FILE__) );
    

    then, to include your file:

    include MYPLUGINNAME_PATH . 'includeme.php';