Access bloginfo, get_option, and plugins_url from a non-core php file

I am creating a plugin that has a php file in the plugin directory which is accessed directly via a custom rewrite url.

I need this file to be able to use the three functions mentioned in the title.

Read More

At the moment, I am including the wp-load.php file which gives me access to all of these functions. However, I’ve been reading that wp-load shouldn’t be included because it may not always be in the same place and it includes wordpress files that may not be needed.

This is how I’m including wp-load:

$wp_base = explode($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_FILENAME']);
require($wp_base[0] . '/wp-load.php');

I’ve found that the functions I need are located in these wordpress files:

wp-includes/general-template.php
wp-includes/functions.php
wp-includes/link-template.php

Should I instead include only these three files, and will they always be located in the same place?

Or is there a better way to go about do this?

Thanks

Related posts

Leave a Reply

1 comment