• Resolved chrismichaels84

    (@chrismichaels84)


    I am developing a site that is partly built on top of CodeIgniter and the other part is using a hacked version of wordpress. So, what I’ve done is “injected” CI functionality into the wordpress by including a global bootstrap via a plugin. The bootstrap defines some constants, loads some functions and does the following to create a $CI object:

    [PHP]// Load it only for WordPress and Elgg
    if ( PN_ENVIRONMENT !== ‘codeigniter’ ) {
    ob_start();
    require(PN_COMMONPATH . ‘/ci-core/pn-ci-inject.php’);
    ob_end_clean();
    $GLOBALS[‘CI’] = get_instance();
    }[/PHP]

    the pn-ci-inject file loads codeigniter using a blank controller. I then flush the buffer, which wonderfully allows me to use

    global $CI

    to access libraries, helpers, etc.

    However, when I did this, something strange broke. Now, in wordpress, my relative paths are not working. So,

    require(‘./admin.php’);

    or

    require(‘../../whatever.php’);

    produces fatal errors. However, when I replace the paths with constants I’ve set with the absolute paths, everything works wonderfully. Again, these relative paths worked fine until I created the $CI object.

    I really, really, don’t want to go through all of wordpress and replace all relative with absolute paths. What did I do? Does anyone have any idea what this is about?

    Thanks all.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Sounds like the working directory got changed for some reason, though I can’t imagine why. You can try echoing out getcwd() before and after to confirm. Regardless, you could chdir() to your WordPress directory to fix the relative links.

    FWIW, I’m not convinced you will find many relative links in WP core files, plugin and theme developers are encouraged to not use relative links because directory structures vary for various reasons. Regardless, changing relative paths in an installation is not a workable solution.

    Thread Starter chrismichaels84

    (@chrismichaels84)

    Thank you, that worked well. The only relative links I have found are many of the requires in wp-admin for whatever reason.

    Thread Starter chrismichaels84

    (@chrismichaels84)

    All works well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘relative paths stopped working in admin’ is closed to new replies.