get_dropins() - WordPress 函数参考中文文档

返回介绍

get_dropins()

发布于 2017-09-10 字数1936 浏览 809 评论 0

get_dropins()

Check the wp-content directory and retrieve all drop-ins with any plugin data.


描述


返回值

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


源代码

File: wp-admin/includes/plugin.php

function get_dropins() {
	$dropins = array();
	$plugin_files = array();

	$_dropins = _get_dropins();

	// These exist in the wp-content directory
	if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) {
		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
			if ( isset( $_dropins[ $file ] ) )
				$plugin_files[] = $file;
		}
	} else {
		return $dropins;
	}

	@closedir( $plugins_dir );

	if ( empty($plugin_files) )
		return $dropins;

	foreach ( $plugin_files as $plugin_file ) {
		if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) )
			continue;
		$plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
		if ( empty( $plugin_data['Name'] ) )
			$plugin_data['Name'] = $plugin_file;
		$dropins[ $plugin_file ] = $plugin_data;
	}

	uksort( $dropins, 'strnatcasecmp' );

	return $dropins;
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-admin/includes/plugin.php:
    _get_dropins()
  • wp-admin/includes/plugin.php:
    get_plugin_data()

Used By

  • wp-admin/includes/class-wp-plugins-list-table.php:
    WP_Plugins_List_Table::prepare_items()

User Contributed Notes

上一篇:get_dirsize()

下一篇:get_editable_authors()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!