get_plugins()获取某个目录下的所有插件信息

目录

描述

Check the plugins directory and retrieve all plugin files with plugin data.

WordPress only supports plugin files in the base plugins directory (wp-content/plugins) and in one directory below the plugins directory (wp-content/plugins/my-plugin). The file it looks for has the plugin data and must be found in those two locations. It is recommended that you keep your plugin files in directories.

The file with the plugin data is the file that will be included and therefore needs to have the main execution for the plugin. This does not mean everything must be contained in the file and it is recommended that the file be split for maintainability. Keep everything in one file for extreme optimization purposes.

get_plugins() 描述

用法

<?php get_plugins$plugin_folder ?>

get_plugins() 用法

参数

$plugin_folder

(string) (可选) Relative path to single plugin folder.

默认值: ''

get_plugins() 参数

返回值

(array) 

Key is the plugin file path and the value is an array of the plugin data.

get_plugins() 返回值

示例

Get All Plugins

The following code snippet returns all plugins installed on your site (not just activated ones).

Example output:

get_plugins() 示例

注意

If you have `PHP Fatal error: Call to undefined function get_plugins()` then you must include the file 'wp-admin/includes/plugin.php' like in example.

get_plugins() 注意

历史

  • 添加于 版本: 1.5.0

get_plugins() 历史

源文件

get_plugins() 函数的代码位于 /wp-admin/includes/plugin.php.

get_plugins() 源文件