• Resolved Josh

    (@josh401)


    Hi,

    I’m trying to include the global $shortcodes variable into one of my plugin files. The file is a tinymce popup plugin… and hence isn’t initialized from within wordpress.

    So, what is the best way to “call” wordpress so that I can include the wp-admin file which is needed for definition of my shortcodes list.

    I was using:

    $file = dirname(__FILE__);
    $file = substr($file, 0, stripos($file, "wp-content") );
    $file2 = dirname(__FILE__);
    $file2 = substr($file2, 0, stripos($file2, "wp-content") );
    require( $file . "/wp-load.php");
    require( $file2 . "/wp-admin/admin.php");

    But, this results in this notice:

    Notice: Undefined offset: 1

    What is the best way to access wordpress global variables from within a plugin file, under this circumstance?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Josh

    (@josh401)

    Okay, it’s not from the above code. That part is working properly.

    Here is the notice when wp-debug is set to true:

    Notice: Undefined offset: 1 in /home/josh401/public_html/multisite/wp-includes/vars.php on line 28

    And I believe the issue is coming from my foreach:

    foreach($shortcode_tags as $tagname=>$tag) {
        echo "<tr><td><a href=\"javascript:;\" onClick=\"tinyMCEPopup.close();\" onmousedown=\"tinyMCE.execCommand('mceInsertContent',false,'[".$tagname."]"." "."[/".$tagname."]');\"> [$tagname]</a></td></tr>";
    }

    Does anyone see a connection?

    Thread Starter Josh

    (@josh401)

    Resolved. Turns out it was from the code I posted in my first comment.

    Hi,

    May I ask how did you resolve it? I am also calling a thickbox which i want to load wp-admin.

    I have the exact same error you have.

    Thread Starter Josh

    (@josh401)

    This is the code I ended up using:

    $file = dirname(__FILE__);
    $file = substr($file, 0, stripos($file, "ultimate-tinymce") );
    require( $file . "../../wp-load.php");

    Basically, the “ultimate-tinymce” is the folder name of my plugin. So, it will locate the ultimate-tinymce folder.. .and go up two levels.. and grab the wp-load.php file.

    You’ll want to change the plugin folder name to your own.

    I don’t think it covers every single custom installation.. but it’s been about 99% effective.

    I’d love to know if there is a better way to do this!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Wordpres Variables from outside file’ is closed to new replies.