vendredi 17 avril 2015

How to use functions provided in wordpress APIs in the my customed php files?

I need to use file_get_contents() in my customed php file for my website powered by wordpress, but such files as fopen(), file_get_contents() are not allowed in wordpress. Instead, it provides its own version of file_get_contents() -- wp_remote_fopen() in the functions.php file located in the /root_dir/wp-includes/functions.php. Now I need to use the wp_remote_fopen() function in my own php file located in the root directory. I added the require() or include() function in my customed php file:



require_once('/wp-includes/functions');


but it didn't work. I add some test code below the require():



$get_file = functions_exists('wp_remote_fopen');
if ($get_file == true) {
echo "get the function!";
} else {
echo "failed!";
}


However, my test code showed that when the require() function was executed, something wrong happened because all other codes below the require() were not executed at all. So how can I use the wp_remote_fopen() or any other functions provided in the wordpress default functions.php file in my customed php files?


Aucun commentaire:

Enregistrer un commentaire