函数文档

wp_dequeue_script_module()

💡 云策文档标注

概述

wp_dequeue_script_module() 函数用于取消标记脚本模块,使其不再在页面中入队。这是 WordPress 6.5.0 版本引入的功能,与 WP_Script_Modules 类相关。

关键要点

  • 函数作用:通过取消标记脚本模块,阻止其在页面中入队。
  • 参数:接受一个必需的字符串参数 $id,表示脚本模块的标识符。
  • 内部实现:调用 wp_script_modules()->dequeue($id) 来执行取消入队操作。
  • 相关函数:与 WP_Script_Modules::dequeue() 和 wp_script_modules() 紧密关联。
  • 使用场景:例如在 WP_Block::render() 中用于生成块渲染输出时控制脚本模块入队。
  • 版本历史:自 WordPress 6.5.0 版本引入。

代码示例

function wp_dequeue_script_module( string $id ) {
	wp_script_modules()->dequeue( $id );
}

📄 原文内容

Unmarks the script module so it is no longer enqueued in the page.

Parameters

$idstringrequired
The identifier of the script module.

Source

function wp_dequeue_script_module( string $id ) {
	wp_script_modules()->dequeue( $id );
}

Changelog

Version Description
6.5.0 Introduced.