^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_mu_plugins()用法示例

get_mu_plugins()

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


描述

WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins).

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


返回值

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


源代码

File: wp-admin/includes/plugin.php

function get_mu_plugins() {
	$wp_plugins = array();
	// Files in wp-content/mu-plugins directory
	$plugin_files = array();

	if ( ! is_dir( WPMU_PLUGIN_DIR ) )
		return $wp_plugins;
	if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) {
		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
			if ( substr( $file, -4 ) == '.php' )
				$plugin_files[] = $file;
		}
	} else {
		return $wp_plugins;
	}

	@closedir( $plugins_dir );

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

	foreach ( $plugin_files as $plugin_file ) {
		if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) )
			continue;

		$plugin_data = get_plugin_data( WPMU_PLUGIN_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;

		$wp_plugins[ $plugin_file ] = $plugin_data;
	}

	if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden
		unset( $wp_plugins['index.php'] );

	uasort( $wp_plugins, '_sort_uname_callback' );

	return $wp_plugins;
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • 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()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈