函数文档

wp_dashboard_primary_output()

💡 云策文档标注

概述

wp_dashboard_primary_output() 函数用于在 WordPress 仪表板中显示事件和新闻源。它通过循环处理 RSS 源数组,并调用 wp_widget_rss_output() 来输出内容。

关键要点

  • 函数用途:显示 WordPress 事件和新闻源,通常用于仪表板小部件。
  • 参数:接受两个必需参数:$widget_id(字符串,小部件 ID)和 $feeds(数组,RSS 源数组)。
  • 内部实现:使用 foreach 循环遍历 $feeds 数组,为每个源设置类型,并调用 wp_widget_rss_output() 来输出 RSS 条目。
  • 相关函数:与 wp_widget_rss_output() 关联,后者负责实际显示 RSS 条目列表。
  • 变更历史:在 WordPress 4.8.0 版本中移除了流行插件源,函数自 3.8.0 版本引入。

📄 原文内容

Displays the WordPress events and news feeds.

Parameters

$widget_idstringrequired
Widget ID.
$feedsarrayrequired
Array of RSS feeds.

Source

function wp_dashboard_primary_output( $widget_id, $feeds ) {
	foreach ( $feeds as $type => $args ) {
		$args['type'] = $type;
		echo '<div class="rss-widget">';
			wp_widget_rss_output( $args['url'], $args );
		echo '</div>';
	}
}

Changelog

Version Description
4.8.0 Removed popular plugins feed.
3.8.0 Introduced.