_response_to_rss

函数
_response_to_rss ( $resp )
参数
  • (array) $resp
    Required:
返回值
  • (MagpieRSS|bool)
定义位置
相关方法
wp_reset_varswp_revisions_to_keepget_oembed_response_data_rich_post_states_get_post_ancestors
引入
1.5.0
弃用
-

_response_to_rss: 这个函数用于为一组给定的文章生成一个RSS feed响应。它将数据格式化为RSS规范要求的适当的XML格式。

function _response_to_rss ($resp) {
	$rss = new MagpieRSS( $resp->results );

	// if RSS parsed successfully
	if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {

		// find Etag, and Last-Modified
		foreach ( (array) $resp->headers as $h) {
			// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
			if (strpos($h, ": ")) {
				list($field, $val) = explode(": ", $h, 2);
			}
			else {
				$field = $h;
				$val = "";
			}

			if ( $field == 'etag' ) {
				$rss->etag = $val;
			}

			if ( $field == 'last-modified' ) {
				$rss->last_modified = $val;
			}
		}

		return $rss;
	} // else construct error message
	else {
		$errormsg = "Failed to parse RSS file.";

		if ($rss) {
			$errormsg .= " (" . $rss->ERROR . ")";
		}
		// error($errormsg);

		return false;
	} // end if ($rss and !$rss->error)
}

常见问题

FAQs
查看更多 >