phpwordpress

What is the shortcut path to the existing plugins folder using file_get_contents()?


My code is inside a plugin's init function and I'm trying to file_get_contents() on a file inside my plugin folder..

I'm using...

file_get_contents(ABSPATH.'/wp-content/plugins/myplugin/myfile.html');

Not sure why can't I just use...

file_get_contents('myfile.html');

Solution

  • Is php file where you call file_get_contents called directly or required from another script? Path to files calculated from file, which run directly. For example: in index.php my be required 'plugins/i/plagin78.php If in plugin78.php you called file_get_contents('myfile.html') then myfile.html should be placed in same category as index.php, not plugin78.php