函数文档

wp_paused_themes()

💡 云策文档标注

概述

wp_paused_themes() 函数用于获取存储暂停主题的 WP_Paused_Extensions_Storage 实例。它通过单例模式确保只创建一个实例,并指定扩展类型为 'theme'。

关键要点

  • 返回 WP_Paused_Extensions_Storage 实例,用于管理暂停的主题
  • 使用静态变量实现单例模式,避免重复创建实例
  • 在 WordPress 恢复模式、主题切换等场景中被相关函数调用

代码示例

function wp_paused_themes() {
    static $storage = null;

    if ( null === $storage ) {
        $storage = new WP_Paused_Extensions_Storage( 'theme' );
    }

    return $storage;
}

注意事项

  • 此函数专用于主题扩展类型,其他扩展类型(如插件)可能有类似函数
  • 确保在需要访问暂停主题存储时调用此函数,以获取正确的单例实例

📄 原文内容

Get the instance for storing paused extensions.

Return

WP_Paused_Extensions_Storage

Source

function wp_paused_themes() {
	static $storage = null;

	if ( null === $storage ) {
		$storage = new WP_Paused_Extensions_Storage( 'theme' );
	}

	return $storage;
}