函数文档

_wp_oembed_get_object()

💡 云策文档标注

概述

_wp_oembed_get_object() 是一个 WordPress 函数,用于返回初始化的 WP_oEmbed 对象实例。它通过静态变量确保单例模式,避免重复创建对象。

关键要点

  • 函数返回 WP_oEmbed 对象,用于处理 oEmbed 相关操作。
  • 使用静态变量实现单例模式,仅在首次调用时创建新实例。
  • 在 WordPress 2.9.0 版本中引入,是 oEmbed 功能的核心组件。

代码示例

function _wp_oembed_get_object() {
    static $wp_oembed = null;

    if ( is_null( $wp_oembed ) ) {
        $wp_oembed = new WP_oEmbed();
    }
    return $wp_oembed;
}

📄 原文内容

Returns the initialized WP_oEmbed object.

Return

WP_oEmbed object.

Source

function _wp_oembed_get_object() {
	static $wp_oembed = null;

	if ( is_null( $wp_oembed ) ) {
		$wp_oembed = new WP_oEmbed();
	}
	return $wp_oembed;
}

Changelog

Version Description
2.9.0 Introduced.