我正在使用WordPress,并且我正在尝试编写一个使用来自另一个插件的文件的插件。获取文件的URL是正确的。当我从类中调用静态函数时,我可以包含这个文件,这说明类没有加载。
//loading the file
$url=plugins_url().'/nextgen-gallery/admin/functions.php';
include $url;文件名为functions.php,其中包含一个类定义的nggAdmin
但是,当我调用function nggAdmin::create_gallery();,时,我得到以下错误:
Fatal error: Class 'nggAdmin' not found in /var/www/html/wordpress/wp-content/plugins/Product/addProductForm.php on line 27发布于 2012-04-23 18:38:21
plugins_url()为您提供url,例如http://example.com/wordpress/wp-plugins/,而不是服务器路径- http://codex.wordpress.org/Function_Reference/plugins_url
改为使用WP_PLUGIN_DIR - http://codex.wordpress.org/Determining_Plugin_and_Content_Directories
https://stackoverflow.com/questions/10278871
复制相似问题