我正在尝试编写简单的 php 脚本,它将返回 Wordpress 的所有插件。
我的代码:
<?php
ini_set('display_errors', 'On');
include('../../../wp-admin/includes/plugin.php');
$all_plugins = get_plugins();
error_log( print_r( $all_plugins, true ) );
我的输出是:
Uncaught Error: Call to undefined function wp_cache_get() in /home/user/domains/mydomain.com/public_html/wp-admin/includes/plugin.php:273 Stack trace: #0 /home/user/domains/mydomain.com/public_html/wp-content/plugins/myplugin/versions.php(6): get_plugins() #1 {main} thrown in /home/user/domains/mydomain.com/public_html/wp-admin/includes/plugin.php on line 273
我使用了以下官方示例:https : //codex.wordpress.org/Function_Reference/get_plugins
我做了:
所以我的 wordpress 是全新的,我仍然有同样的错误。有人知道怎么解决吗?
要加载所有 WordPress 功能,您需要包含该文件wp-load.php
:
require_once("../../../../wp-load.php");
而不是插件之一。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句