我想你必须更具体地说明到底是什么功能。Wordpress 不提供开箱即用的功能,大多数 PHP 应用程序不会。
我还认为,如果没有为此类环境开发此类应用程序,那么您就是在找麻烦。
这是一个尝试从functions.php调用“current_time()”的示例,我必须做的尝试只是为了意识到它不会那样工作:
php -r 'require "functions.php"; var_dump(current_time("mysql"));'
给
Fatal error: Call to undefined function apply_filters() in functions.php on line 346
试
php -r 'require "functions.php"; require "plugin.php"; var_dump(current_time("mysql"));'
给
Fatal error: Call to undefined function wp_cache_get() in functions.php on line 351
试
php -r 'require "functions.php"; require "plugin.php"; require "cache.php"; var_dump(current_time("mysql"));'
给
Fatal error: Call to a member function get() on a non-object in cache.php on line 93
查看我看到的源代码中的最后一个错误
function wp_cache_get($id, $flag = '') {
global $wp_object_cache;
return $wp_object_cache->get($id, $flag);
}
如果不是不可能的话,使用全局变量可以使在其他环境中进行测试成为 PITA。
如果这不是您想要做的,那么您的问题必须更加具体/详细。