函数文档

enqueue_comment_hotkeys_js()

💡 云策文档标注

概述

enqueue_comment_hotkeys_js() 函数用于在 WordPress 中根据用户设置,有条件地加载评论快捷键的 jQuery 脚本。

关键要点

  • 函数检查用户选项 'comment_shortcuts' 是否为 'true',以决定是否加载脚本。
  • 使用 wp_enqueue_script() 来安全地加载 'jquery-table-hotkeys' 脚本。
  • 该函数自 WordPress 2.7.0 版本引入。

代码示例

function enqueue_comment_hotkeys_js() {
	if ( 'true' === get_user_option( 'comment_shortcuts' ) ) {
		wp_enqueue_script( 'jquery-table-hotkeys' );
	}
}

📄 原文内容

Enqueues comment shortcuts jQuery script.

Source

function enqueue_comment_hotkeys_js() {
	if ( 'true' === get_user_option( 'comment_shortcuts' ) ) {
		wp_enqueue_script( 'jquery-table-hotkeys' );
	}
}

Changelog

Version Description
2.7.0 Introduced.